Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -fsyntax-only |
Steve Naroff | 3f0c5ad | 2008-01-14 21:38:57 +0000 | [diff] [blame] | 2 | |
| 3 | void a() { |
| 4 | __complex__ int arr; |
| 5 | __complex__ short brr; |
Steve Naroff | 14f3f1b | 2008-01-14 23:33:18 +0000 | [diff] [blame] | 6 | __complex__ unsigned xx; |
| 7 | __complex__ signed yy; |
Steve Naroff | 3f0c5ad | 2008-01-14 21:38:57 +0000 | [diff] [blame] | 8 | __complex__ int result; |
Steve Naroff | 4cdec1c | 2008-01-15 01:41:59 +0000 | [diff] [blame] | 9 | int ii; |
Steve Naroff | 02f62a9 | 2008-01-15 19:36:10 +0000 | [diff] [blame] | 10 | int aa = 1 + 1.0iF; |
Steve Naroff | 4cdec1c | 2008-01-15 01:41:59 +0000 | [diff] [blame] | 11 | |
| 12 | result = arr*ii; |
| 13 | result = ii*brr; |
Steve Naroff | 3f0c5ad | 2008-01-14 21:38:57 +0000 | [diff] [blame] | 14 | |
| 15 | result = arr*brr; |
Steve Naroff | 14f3f1b | 2008-01-14 23:33:18 +0000 | [diff] [blame] | 16 | result = xx*yy; |
Steve Naroff | 4cdec1c | 2008-01-15 01:41:59 +0000 | [diff] [blame] | 17 | |
| 18 | switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}} |
Anders Carlsson | d3a61d5 | 2008-12-01 02:13:02 +0000 | [diff] [blame] | 19 | case brr: ; // expected-error{{expression is not an integer constant expression}} |
| 20 | case xx: ; // expected-error{{expression is not an integer constant expression}} |
Douglas Gregor | acb0bd8 | 2010-06-29 23:25:20 +0000 | [diff] [blame] | 21 | } |
Steve Naroff | 3f0c5ad | 2008-01-14 21:38:57 +0000 | [diff] [blame] | 22 | } |
| 23 | |
Steve Naroff | dfb9bbb | 2008-01-15 22:21:49 +0000 | [diff] [blame] | 24 | void Tester() { |
| 25 | __complex short a1; |
| 26 | __complex int a2; |
| 27 | __complex float a3; |
| 28 | __complex double a4; |
| 29 | short a5; |
| 30 | int a6; |
| 31 | float a7; |
| 32 | double a8; |
| 33 | #define TestPair(m,n) int x##m##n = a##m+a##n; |
| 34 | #define TestPairs(m) TestPair(m,1) TestPair(m,2) \ |
| 35 | TestPair(m,3) TestPair(m,4) \ |
| 36 | TestPair(m,5) TestPair(m,6) \ |
| 37 | TestPair(m,7) TestPair(m,8) |
| 38 | TestPairs(1); TestPairs(2); |
| 39 | TestPairs(3); TestPairs(4); |
| 40 | TestPairs(5); TestPairs(6); |
| 41 | TestPairs(7); TestPairs(8); |
| 42 | } |
| 43 | |
Chris Lattner | 02a6514 | 2008-07-25 23:52:49 +0000 | [diff] [blame] | 44 | // rdar://6097730 |
| 45 | void test3(_Complex int *x) { |
| 46 | *x = ~*x; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 47 | } |
Chris Lattner | 02a6514 | 2008-07-25 23:52:49 +0000 | [diff] [blame] | 48 | |
| 49 | void test4(_Complex float *x) { |
| 50 | *x = ~*x; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 51 | } |
Eli Friedman | 5b088a1 | 2010-01-03 00:20:48 +0000 | [diff] [blame] | 52 | |
| 53 | void test5(_Complex int *x) { |
| 54 | (*x)++; |
| 55 | } |
Abramo Bagnara | 96fc8e4 | 2010-12-11 16:05:48 +0000 | [diff] [blame] | 56 | |
| 57 | int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1]; |
| 58 | int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1]; |
| 59 | int i3[-(2+3i) == +(-3i-2) ? 1 : -1]; |
| 60 | int i4[~(2+3i) == 2-3i ? 1 : -1]; |
| 61 | int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1]; |
| 62 | |
| 63 | int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1]; |
| 64 | int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1]; |
| 65 | int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1]; |
| 66 | int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1]; |
| 67 | int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1]; |