Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -emit-llvm-only %s
      2 
      3 int 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 
     15 void 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 
     26 void test3() {
     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;
     44 void test3int() {
     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 
     59 void t1() {
     60   (__real__ cf) = 4.0;
     61 }
     62 
     63 void t2() {
     64   (__imag__ cf) = 4.0;
     65 }
     66 
     67 // PR1960
     68 void t3() {
     69   __complex__ long long v = 2;
     70 }
     71 
     72 // PR3131
     73 float _Complex t4();
     74 
     75 void t5() {
     76   float _Complex x = t4();
     77 }
     78 
     79 void t6() {
     80   g1++;
     81   g1--;
     82   ++g1;
     83   --g1;
     84   ci1++;
     85   ci1--;
     86   ++ci1;
     87   --ci1;
     88 }
     89 
     90 // <rdar://problem/7958272>
     91 double t7(double _Complex c) {
     92   return __builtin_fabs(__real__(c));
     93 }
     94 
     95 void t8() {
     96   __complex__ int *x = &(__complex__ int){1};
     97 }
     98 
     99 const _Complex double test9const = 0;
    100 _Complex double test9func() { return test9const; }
    101 
    102 // D6217
    103 void t91() {
    104   // Check for proper type promotion of conditional expression
    105   char c[(int)(sizeof(typeof((0 ? 2.0f : (_Complex double) 2.0f))) - sizeof(_Complex double))];
    106   // Check for proper codegen
    107   (0 ? 2.0f : (_Complex double) 2.0f);
    108 }
    109 
    110 void t92() {
    111   // Check for proper type promotion of conditional expression
    112   char c[(int)(sizeof(typeof((0 ? (_Complex double) 2.0f : 2.0f))) - sizeof(_Complex double))];
    113   // Check for proper codegen
    114   (0 ? (_Complex double) 2.0f : 2.0f);
    115 }
    116 
    117