Eli Friedman | 5b088a1 | 2010-01-03 00:20:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm-only %s |
Gabor Greif | bacfa02 | 2007-07-13 22:15:44 +0000 | [diff] [blame] | 2 | |
Gabor Greif | b02d4b4 | 2007-07-13 23:40:27 +0000 | [diff] [blame] | 3 | int main(void) |
Gabor Greif | bacfa02 | 2007-07-13 22:15:44 +0000 | [diff] [blame] | 4 | { |
5 | double _Complex a = 5; | ||||
6 | double _Complex b = 42; | ||||
7 | |||||
Gabor Greif | b02d4b4 | 2007-07-13 23:40:27 +0000 | [diff] [blame] | 8 | return a * b != b * a; |
Gabor Greif | bacfa02 | 2007-07-13 22:15:44 +0000 | [diff] [blame] | 9 | } |
Chris Lattner | 12b2be2 | 2007-08-10 17:02:59 +0000 | [diff] [blame] | 10 | |
11 | _Complex double bar(int); | ||||
12 | void test(_Complex double*); | ||||
Chris Lattner | fd90ac0 | 2007-08-23 23:49:47 +0000 | [diff] [blame] | 13 | void takecomplex(_Complex double); |
Chris Lattner | 12b2be2 | 2007-08-10 17:02:59 +0000 | [diff] [blame] | 14 | |
15 | void test2(int c) { | ||||
16 | _Complex double X; | ||||
17 | X = bar(1); | ||||
18 | test(&X); | ||||
Chris Lattner | fd90ac0 | 2007-08-23 23:49:47 +0000 | [diff] [blame] | 19 | takecomplex(X); |
Chris Lattner | 12b2be2 | 2007-08-10 17:02:59 +0000 | [diff] [blame] | 20 | } |
21 | |||||
Chris Lattner | fd90ac0 | 2007-08-23 23:49:47 +0000 | [diff] [blame] | 22 | _Complex double g1, g2; |
Chris Lattner | 8ae3a9f | 2007-08-26 22:41:57 +0000 | [diff] [blame] | 23 | _Complex float cf; |
24 | double D; | ||||
Chris Lattner | fd90ac0 | 2007-08-23 23:49:47 +0000 | [diff] [blame] | 25 | |
26 | void test3() { | ||||
27 | g1 = g1 + g2; | ||||
28 | g1 = g1 - g2; | ||||
29 | g1 = g1 * g2; | ||||
30 | g1 = +-~g1; | ||||
Chris Lattner | 46f93d0 | 2007-08-24 21:20:17 +0000 | [diff] [blame] | 31 | |
32 | double Gr = __real g1; | ||||
Chris Lattner | 8ae3a9f | 2007-08-26 22:41:57 +0000 | [diff] [blame] | 33 | |
Chris Lattner | 9cff1a9 | 2007-08-27 16:37:44 +0000 | [diff] [blame] | 34 | cf += D; |
Eli Friedman | ab3a852 | 2009-03-28 01:22:36 +0000 | [diff] [blame] | 35 | // FIXME: Currently unsupported! |
36 | //D += cf; | ||||
Chris Lattner | 8ae3a9f | 2007-08-26 22:41:57 +0000 | [diff] [blame] | 37 | cf /= g1; |
Chris Lattner | 9cff1a9 | 2007-08-27 16:37:44 +0000 | [diff] [blame] | 38 | g1 = g1 + D; |
39 | g1 = D + g1; | ||||
Chris Lattner | fd90ac0 | 2007-08-23 23:49:47 +0000 | [diff] [blame] | 40 | } |
Chris Lattner | 7da36f6 | 2007-10-30 22:53:42 +0000 | [diff] [blame] | 41 | |
Eli Friedman | 5b088a1 | 2010-01-03 00:20:48 +0000 | [diff] [blame] | 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 | |||||
Chris Lattner | 7da36f6 | 2007-10-30 22:53:42 +0000 | [diff] [blame] | 61 | void t1() { |
62 | (__real__ cf) = 4.0; | ||||
63 | } | ||||
64 | |||||
65 | void t2() { | ||||
66 | (__imag__ cf) = 4.0; | ||||
67 | } | ||||
68 | |||||
Chris Lattner | 9b2dc28 | 2008-04-04 16:54:41 +0000 | [diff] [blame] | 69 | // PR1960 |
70 | void t3() { | ||||
71 | __complex__ long long v = 2; | ||||
72 | } | ||||
73 | |||||
Anders Carlsson | ad3d691 | 2008-11-25 22:21:48 +0000 | [diff] [blame] | 74 | // PR3131 |
75 | float _Complex t4(); | ||||
76 | |||||
77 | void t5() { | ||||
78 | float _Complex x = t4(); | ||||
79 | } | ||||
80 | |||||
Eli Friedman | 5b088a1 | 2010-01-03 00:20:48 +0000 | [diff] [blame] | 81 | void t6() { |
82 | g1++; | ||||
83 | g1--; | ||||
84 | ++g1; | ||||
85 | --g1; | ||||
86 | ci1++; | ||||
87 | ci1--; | ||||
88 | ++ci1; | ||||
89 | --ci1; | ||||
90 | } | ||||
91 | |||||
John McCall | abd3a85 | 2010-05-07 22:08:54 +0000 | [diff] [blame] | 92 | // <rdar://problem/7958272> |
93 | double t7(double _Complex c) { | ||||
94 | return __builtin_fabs(__real__(c)); | ||||
95 | } | ||||
Eli Friedman | 43e890b | 2011-06-15 20:17:07 +0000 | [diff] [blame] | 96 | |
97 | void t8() { | ||||
98 | __complex__ int *x = &(__complex__ int){1}; | ||||
99 | } |