1 // RUN: %clang_cc1 -emit-llvm-only %s 2 main(void)3int main(void) 4 { 5 double _Complex a = 5; 6 double _Complex b = 42; 7 8 return a * b != b * a; 9 } 10 11 _Complex double bar(int); 12 void test(_Complex double*); 13 void takecomplex(_Complex double); 14 test2(int c)15void test2(int c) { 16 _Complex double X; 17 X = bar(1); 18 test(&X); 19 takecomplex(X); 20 } 21 22 _Complex double g1, g2; 23 _Complex float cf; 24 double D; 25 test3(void)26void test3(void) { 27 g1 = g1 + g2; 28 g1 = g1 - g2; 29 g1 = g1 * g2; 30 g1 = +-~g1; 31 32 double Gr = __real g1; 33 34 cf += D; 35 D += cf; 36 cf /= g1; 37 g1 = g1 + D; 38 g1 = D + g1; 39 } 40 41 __complex__ int ci1, ci2; 42 __complex__ short cs; 43 int i; test3int(void)44void test3int(void) { 45 ci1 = ci1 + ci2; 46 ci1 = ci1 - ci2; 47 ci1 = ci1 * ci2; 48 ci1 = +-~ci1; 49 50 i = __real ci1; 51 52 cs += i; 53 D += cf; 54 cs /= ci1; 55 ci1 = ci1 + i; 56 ci1 = i + ci1; 57 } 58 t1(void)59void t1(void) { 60 (__real__ cf) = 4.0; 61 } 62 t2(void)63void t2(void) { 64 (__imag__ cf) = 4.0; 65 } 66 67 // PR1960 t3(void)68void t3(void) { 69 __complex__ long long v = 2; 70 } 71 72 // PR3131 73 float _Complex t4(void); 74 t5(void)75void t5(void) { 76 float _Complex x = t4(); 77 } 78 t6(void)79void t6(void) { 80 g1++; 81 g1--; 82 ++g1; 83 --g1; 84 ci1++; 85 ci1--; 86 ++ci1; 87 --ci1; 88 } 89 t7(double _Complex c)90double t7(double _Complex c) { 91 return __builtin_fabs(__real__(c)); 92 } 93 t8(void)94void t8(void) { 95 __complex__ int *x = &(__complex__ int){1}; 96 } 97 98 const _Complex double test9const = 0; test9func(void)99_Complex double test9func(void) { return test9const; } 100 101 // D6217 t91(void)102void t91(void) { 103 // Check for proper type promotion of conditional expression 104 char c[(int)(sizeof(typeof((0 ? 2.0f : (_Complex double) 2.0f))) - sizeof(_Complex double))]; 105 // Check for proper codegen 106 (0 ? 2.0f : (_Complex double) 2.0f); 107 } 108 t92(void)109void t92(void) { 110 // Check for proper type promotion of conditional expression 111 char c[(int)(sizeof(typeof((0 ? (_Complex double) 2.0f : 2.0f))) - sizeof(_Complex double))]; 112 // Check for proper codegen 113 (0 ? (_Complex double) 2.0f : 2.0f); 114 } 115 116