78 lines · c
1// RUN: %clang_cc1 %s -verify -fsyntax-only2 3void a(void) {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;11int bb = 0;12bb += 1i;13 14typedef __complex__ float ComplexFloat;15int cc = 1 + (ComplexFloat)(1.0iF);16 17result = arr*ii;18result = ii*brr;19 20result = arr*brr;21result = xx*yy;22 23switch (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}}26}27switch (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}}30}31}32 33void Tester(void) {34__complex short a1;35__complex int a2;36__complex float a3;37__complex double a4;38short a5;39int a6;40float a7;41double 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)47TestPairs(1); TestPairs(2);48TestPairs(3); TestPairs(4);49TestPairs(5); TestPairs(6);50TestPairs(7); TestPairs(8);51}52 53void test3(_Complex int *x) {54 *x = ~*x;55}56 57void test4(_Complex float *x) {58 *x = ~*x;59}60 61void test5(_Complex int *x) {62 (*x)++;63}64 65// None of these array bounds is an ICE due to the use of literals of66// non-integer type. But we can constant-fold all of them.67int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1]; // expected-warning {{fold}}68int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1]; // expected-warning {{fold}}69int i3[-(2+3i) == +(-3i-2) ? 1 : -1]; // expected-warning {{fold}}70int i4[~(2+3i) == 2-3i ? 1 : -1]; // expected-warning {{fold}}71int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1]; // expected-warning {{fold}}72 73int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1]; // expected-warning {{fold}}74int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1]; // expected-warning {{fold}}75int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1]; // expected-warning {{fold}}76int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1]; // expected-warning {{fold}}77int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1]; // expected-warning {{fold}}78