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