• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  // RUN: %clang_cc1 -emit-llvm-only %s
2  
main(void)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  
test2(int c)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  
test3()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;
test3int()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  
t1()59  void t1() {
60    (__real__ cf) = 4.0;
61  }
62  
t2()63  void t2() {
64    (__imag__ cf) = 4.0;
65  }
66  
67  // PR1960
t3()68  void t3() {
69    __complex__ long long v = 2;
70  }
71  
72  // PR3131
73  float _Complex t4();
74  
t5()75  void t5() {
76    float _Complex x = t4();
77  }
78  
t6()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>
t7(double _Complex c)91  double t7(double _Complex c) {
92    return __builtin_fabs(__real__(c));
93  }
94  
t8()95  void t8() {
96    __complex__ int *x = &(__complex__ int){1};
97  }
98  
99  const _Complex double test9const = 0;
test9func()100  _Complex double test9func() { return test9const; }
101  
102  // D6217
t91()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  
t92()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