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   // FIXME: Currently unsupported!
     36   //D += cf;
     37   cf /= g1;
     38   g1 = g1 + D;
     39   g1 = D + g1;
     40 }
     41 
     42 __complex__ int ci1, ci2;
     43 __complex__ short cs;
     44 int i;
     45 void test3int() {
     46   ci1 = ci1 + ci2;
     47   ci1 = ci1 - ci2;
     48   ci1 = ci1 * ci2;
     49   ci1 = +-~ci1;
     50 
     51   i = __real ci1;
     52 
     53   cs += i;
     54   // FIXME: Currently unsupported!
     55   //D += cf;
     56   cs /= ci1;
     57   ci1 = ci1 + i;
     58   ci1 = i + ci1;
     59 }
     60 
     61 void t1() {
     62   (__real__ cf) = 4.0;
     63 }
     64 
     65 void t2() {
     66   (__imag__ cf) = 4.0;
     67 }
     68 
     69 // PR1960
     70 void t3() {
     71   __complex__ long long v = 2;
     72 }
     73 
     74 // PR3131
     75 float _Complex t4();
     76 
     77 void t5() {
     78   float _Complex x = t4();
     79 }
     80 
     81 void t6() {
     82   g1++;
     83   g1--;
     84   ++g1;
     85   --g1;
     86   ci1++;
     87   ci1--;
     88   ++ci1;
     89   --ci1;
     90 }
     91 
     92 // <rdar://problem/7958272>
     93 double t7(double _Complex c) {
     94   return __builtin_fabs(__real__(c));
     95 }
     96 
     97 void t8() {
     98   __complex__ int *x = &(__complex__ int){1};
     99 }
    100