blob: 2b797e5a14ad686b753039edded4ccd5312a2e8c [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -verify -fsyntax-only
Steve Naroffc28f46c2008-01-14 21:38:57 +00002
3void a() {
4__complex__ int arr;
5__complex__ short brr;
Steve Naroffd8c7d482008-01-14 23:33:18 +00006__complex__ unsigned xx;
7__complex__ signed yy;
Steve Naroffc28f46c2008-01-14 21:38:57 +00008__complex__ int result;
Steve Naroff7f988882008-01-15 01:41:59 +00009int ii;
Steve Naroff6fcfd052008-01-15 19:36:10 +000010int aa = 1 + 1.0iF;
Josh Magee4d1a79b2015-02-04 21:50:20 +000011int bb = 0;
12bb += 1i;
Steve Naroff7f988882008-01-15 01:41:59 +000013
14result = arr*ii;
15result = ii*brr;
Steve Naroffc28f46c2008-01-14 21:38:57 +000016
17result = arr*brr;
Steve Naroffd8c7d482008-01-14 23:33:18 +000018result = xx*yy;
Steve Naroff7f988882008-01-15 01:41:59 +000019
20switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
Anders Carlssonf7fba462008-12-01 02:13:02 +000021 case brr: ; // expected-error{{expression is not an integer constant expression}}
22 case xx: ; // expected-error{{expression is not an integer constant expression}}
Douglas Gregor5823da32010-06-29 23:25:20 +000023}
Steve Naroffc28f46c2008-01-14 21:38:57 +000024}
25
Steve Naroffabefc392008-01-15 22:21:49 +000026void Tester() {
27__complex short a1;
28__complex int a2;
29__complex float a3;
30__complex double a4;
31short a5;
32int a6;
33float a7;
34double a8;
35#define TestPair(m,n) int x##m##n = a##m+a##n;
36#define TestPairs(m) TestPair(m,1) TestPair(m,2) \
37 TestPair(m,3) TestPair(m,4) \
38 TestPair(m,5) TestPair(m,6) \
39 TestPair(m,7) TestPair(m,8)
40TestPairs(1); TestPairs(2);
41TestPairs(3); TestPairs(4);
42TestPairs(5); TestPairs(6);
43TestPairs(7); TestPairs(8);
44}
45
Chris Lattner0d707612008-07-25 23:52:49 +000046// rdar://6097730
47void test3(_Complex int *x) {
48 *x = ~*x;
Mike Stump11289f42009-09-09 15:08:12 +000049}
Chris Lattner0d707612008-07-25 23:52:49 +000050
51void test4(_Complex float *x) {
52 *x = ~*x;
Mike Stump11289f42009-09-09 15:08:12 +000053}
Eli Friedman090addd2010-01-03 00:20:48 +000054
55void test5(_Complex int *x) {
56 (*x)++;
57}
Abramo Bagnara9e0e7092010-12-11 16:05:48 +000058
59int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1];
60int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1];
61int i3[-(2+3i) == +(-3i-2) ? 1 : -1];
62int i4[~(2+3i) == 2-3i ? 1 : -1];
63int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1];
64
65int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1];
66int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1];
67int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1];
68int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1];
69int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1];