blob: bcd9939b29324ce81136da4f37d049f42c38fa97 [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)}}
Douglas Gregorc30614b2010-06-29 23:17:37 +000019 default: ;
20}
21
22 switch (ii) {
Anders Carlssond3a61d52008-12-01 02:13:02 +000023 case brr: ; // expected-error{{expression is not an integer constant expression}}
24 case xx: ; // expected-error{{expression is not an integer constant expression}}
Douglas Gregorc30614b2010-06-29 23:17:37 +000025 }
Steve Naroff3f0c5ad2008-01-14 21:38:57 +000026}
27
Steve Naroffdfb9bbb2008-01-15 22:21:49 +000028void Tester() {
29__complex short a1;
30__complex int a2;
31__complex float a3;
32__complex double a4;
33short a5;
34int a6;
35float a7;
36double a8;
37#define TestPair(m,n) int x##m##n = a##m+a##n;
38#define TestPairs(m) TestPair(m,1) TestPair(m,2) \
39 TestPair(m,3) TestPair(m,4) \
40 TestPair(m,5) TestPair(m,6) \
41 TestPair(m,7) TestPair(m,8)
42TestPairs(1); TestPairs(2);
43TestPairs(3); TestPairs(4);
44TestPairs(5); TestPairs(6);
45TestPairs(7); TestPairs(8);
46}
47
Chris Lattner02a65142008-07-25 23:52:49 +000048// rdar://6097730
49void test3(_Complex int *x) {
50 *x = ~*x;
Mike Stump1eb44332009-09-09 15:08:12 +000051}
Chris Lattner02a65142008-07-25 23:52:49 +000052
53void test4(_Complex float *x) {
54 *x = ~*x;
Mike Stump1eb44332009-09-09 15:08:12 +000055}
Eli Friedman5b088a12010-01-03 00:20:48 +000056
57void test5(_Complex int *x) {
58 (*x)++;
59}