complex-int.c revision 02a65146aaa1f209013415e9247771805ca2ad5d
1// RUN: clang %s -verify -fsyntax-only
2
3void a() {
4__complex__ int arr;
5__complex__ short brr;
6__complex__ unsigned xx;
7__complex__ signed yy;
8__complex__ int result;
9int ii;
10int aa = 1 + 1.0iF;
11
12result = arr*ii;
13result = ii*brr;
14
15result = arr*brr;
16result = xx*yy;
17
18switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
19  case brr: ; // expected-error{{case label does not reduce to an integer constant}}
20  case xx: ; // expected-error{{case label does not reduce to an integer constant}}
21}
22}
23
24void Tester() {
25__complex short a1;
26__complex int a2;
27__complex float a3;
28__complex double a4;
29short a5;
30int a6;
31float a7;
32double a8;
33#define TestPair(m,n) int x##m##n = a##m+a##n;
34#define TestPairs(m) TestPair(m,1) TestPair(m,2) \
35                    TestPair(m,3) TestPair(m,4) \
36                    TestPair(m,5) TestPair(m,6) \
37                    TestPair(m,7) TestPair(m,8)
38TestPairs(1); TestPairs(2);
39TestPairs(3); TestPairs(4);
40TestPairs(5); TestPairs(6);
41TestPairs(7); TestPairs(8);
42}
43
44// rdar://6097730
45void test3(_Complex int *x) {
46  *x = ~*x;
47}
48
49void test4(_Complex float *x) {
50  *x = ~*x;
51}
52
53