[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / complex-int.c
blobe5a9a947d037085747dd87e7c493c2f20157570d
1 // RUN: %clang_cc1 %s -verify -fsyntax-only
3 void a(void) {
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;
14 typedef __complex__ float ComplexFloat;
15 int cc = 1 + (ComplexFloat)(1.0iF);
17 result = arr*ii;
18 result = ii*brr;
20 result = arr*brr;
21 result = xx*yy;
23 switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
24 case brr: ; // expected-error{{integer constant expression must have integer type}}
25 case xx: ; // expected-error{{integer constant expression must have integer type}}
27 switch (ii) {
28 case brr: ; // expected-error{{integer constant expression must have integer type}}
29 case xx: ; // expected-error{{integer constant expression must have integer type}}
33 void Tester(void) {
34 __complex short a1;
35 __complex int a2;
36 __complex float a3;
37 __complex double a4;
38 short a5;
39 int a6;
40 float a7;
41 double a8;
42 #define TestPair(m,n) int x##m##n = a##m+a##n;
43 #define TestPairs(m) TestPair(m,1) TestPair(m,2) \
44 TestPair(m,3) TestPair(m,4) \
45 TestPair(m,5) TestPair(m,6) \
46 TestPair(m,7) TestPair(m,8)
47 TestPairs(1); TestPairs(2);
48 TestPairs(3); TestPairs(4);
49 TestPairs(5); TestPairs(6);
50 TestPairs(7); TestPairs(8);
53 void test3(_Complex int *x) {
54 *x = ~*x;
57 void test4(_Complex float *x) {
58 *x = ~*x;
61 void test5(_Complex int *x) {
62 (*x)++;
65 // None of these array bounds is an ICE due to the use of literals of
66 // non-integer type. But we can constant-fold all of them.
67 int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1]; // expected-warning {{fold}}
68 int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1]; // expected-warning {{fold}}
69 int i3[-(2+3i) == +(-3i-2) ? 1 : -1]; // expected-warning {{fold}}
70 int i4[~(2+3i) == 2-3i ? 1 : -1]; // expected-warning {{fold}}
71 int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1]; // expected-warning {{fold}}
73 int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1]; // expected-warning {{fold}}
74 int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1]; // expected-warning {{fold}}
75 int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1]; // expected-warning {{fold}}
76 int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1]; // expected-warning {{fold}}
77 int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1]; // expected-warning {{fold}}