blob: 32249b35e1c5a02a59a67f133cdcf4ff0fcd20eb [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -verify -fsyntax-only
Steve Naroff3f0c5ad2008-01-14 21:38:57 +00002
3void a() {
4__complex__ int arr;
5__complex__ short brr;
Steve Naroff14f3f1b2008-01-14 23:33:18 +00006__complex__ unsigned xx;
7__complex__ signed yy;
Steve Naroff3f0c5ad2008-01-14 21:38:57 +00008__complex__ int result;
Steve Naroff4cdec1c2008-01-15 01:41:59 +00009int ii;
Steve Naroff02f62a92008-01-15 19:36:10 +000010int aa = 1 + 1.0iF;
Steve Naroff4cdec1c2008-01-15 01:41:59 +000011
12result = arr*ii;
13result = ii*brr;
Steve Naroff3f0c5ad2008-01-14 21:38:57 +000014
15result = arr*brr;
Steve Naroff14f3f1b2008-01-14 23:33:18 +000016result = xx*yy;
Steve Naroff4cdec1c2008-01-15 01:41:59 +000017
18switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
Anders Carlssond3a61d52008-12-01 02:13:02 +000019 case brr: ; // expected-error{{expression is not an integer constant expression}}
20 case xx: ; // expected-error{{expression is not an integer constant expression}}
Douglas Gregoracb0bd82010-06-29 23:25:20 +000021}
Steve Naroff3f0c5ad2008-01-14 21:38:57 +000022}
23
Steve Naroffdfb9bbb2008-01-15 22:21:49 +000024void Tester() {
25__complex short a1;
26__complex int a2;
27__complex float a3;
28__complex double a4;
29short a5;
30int a6;
31float a7;
32double 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)
38TestPairs(1); TestPairs(2);
39TestPairs(3); TestPairs(4);
40TestPairs(5); TestPairs(6);
41TestPairs(7); TestPairs(8);
42}
43
Chris Lattner02a65142008-07-25 23:52:49 +000044// rdar://6097730
45void test3(_Complex int *x) {
46 *x = ~*x;
Mike Stump1eb44332009-09-09 15:08:12 +000047}
Chris Lattner02a65142008-07-25 23:52:49 +000048
49void test4(_Complex float *x) {
50 *x = ~*x;
Mike Stump1eb44332009-09-09 15:08:12 +000051}
Eli Friedman5b088a12010-01-03 00:20:48 +000052
53void test5(_Complex int *x) {
54 (*x)++;
55}
Abramo Bagnara96fc8e42010-12-11 16:05:48 +000056
57int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1];
58int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1];
59int i3[-(2+3i) == +(-3i-2) ? 1 : -1];
60int i4[~(2+3i) == 2-3i ? 1 : -1];
61int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1];
62
63int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1];
64int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1];
65int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1];
66int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1];
67int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1];