1 | // RUN: %clang_cc1 %s -verify -fsyntax-only |
2 | |
3 | void a() { |
4 | __complex__ int arr; |
5 | __complex__ short brr; |
6 | __complex__ unsigned xx; |
7 | __complex__ signed yy; |
8 | __complex__ int result; |
9 | int ii; |
10 | int aa = 1 + 1.0iF; |
11 | int bb = 0; |
12 | bb += 1i; |
13 | |
14 | result = arr*ii; |
15 | result = ii*brr; |
16 | |
17 | result = arr*brr; |
18 | result = xx*yy; |
19 | |
20 | switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}} |
21 | case brr: ; |
22 | case xx: ; |
23 | } |
24 | switch (ii) { |
25 | case brr: ; // expected-error{{expression is not an integer constant expression}} |
26 | case xx: ; // expected-error{{expression is not an integer constant expression}} |
27 | } |
28 | } |
29 | |
30 | void Tester() { |
31 | __complex short a1; |
32 | __complex int a2; |
33 | __complex float a3; |
34 | __complex double a4; |
35 | short a5; |
36 | int a6; |
37 | float a7; |
38 | double a8; |
39 | #define TestPair(m,n) int x##m##n = a##m+a##n; |
40 | #define TestPairs(m) TestPair(m,1) TestPair(m,2) \ |
41 | TestPair(m,3) TestPair(m,4) \ |
42 | TestPair(m,5) TestPair(m,6) \ |
43 | TestPair(m,7) TestPair(m,8) |
44 | TestPairs(1); TestPairs(2); |
45 | TestPairs(3); TestPairs(4); |
46 | TestPairs(5); TestPairs(6); |
47 | TestPairs(7); TestPairs(8); |
48 | } |
49 | |
50 | // rdar://6097730 |
51 | void test3(_Complex int *x) { |
52 | *x = ~*x; |
53 | } |
54 | |
55 | void test4(_Complex float *x) { |
56 | *x = ~*x; |
57 | } |
58 | |
59 | void test5(_Complex int *x) { |
60 | (*x)++; |
61 | } |
62 | |
63 | int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1]; |
64 | int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1]; |
65 | int i3[-(2+3i) == +(-3i-2) ? 1 : -1]; |
66 | int i4[~(2+3i) == 2-3i ? 1 : -1]; |
67 | int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1]; |
68 | |
69 | int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1]; |
70 | int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1]; |
71 | int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1]; |
72 | int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1]; |
73 | int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1]; |
74 | |