blob: 0d1b6c945c5c0a1aa7dfbaa195638170fe4a5a15 [file] [log] [blame]
Douglas Gregor87c30072010-07-26 04:08:02 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Reid Spencer5f016e22007-07-11 17:01:13 +00002
3void test1() {
Douglas Gregor87c30072010-07-26 04:08:02 +00004 if (sizeof (int){ 1}) {} // sizeof compound literal
5 if (sizeof (int)) {} // sizeof type
Reid Spencer5f016e22007-07-11 17:01:13 +00006
Douglas Gregor87c30072010-07-26 04:08:02 +00007 (void)(int)4; // cast.
8 (void)(int){4}; // compound literal.
Reid Spencer5f016e22007-07-11 17:01:13 +00009
Douglas Gregor87c30072010-07-26 04:08:02 +000010 int A = (struct{ int a;}){ 1}.a;
Reid Spencer5f016e22007-07-11 17:01:13 +000011}
12
13int test2(int a, int b) {
Douglas Gregor87c30072010-07-26 04:08:02 +000014 return a ? (void)a,b : a;
Reid Spencer5f016e22007-07-11 17:01:13 +000015}
16
17int test3(int a, int b, int c) {
18 return a = b = c;
19}
20
21int test4() {
22 test4();
Douglas Gregor87c30072010-07-26 04:08:02 +000023 return 0;
Reid Spencer5f016e22007-07-11 17:01:13 +000024}
25
Douglas Gregor87c30072010-07-26 04:08:02 +000026struct X0 { struct { struct { int c[10][9]; } b; } a; };
27
Reid Spencer5f016e22007-07-11 17:01:13 +000028int test_offsetof() {
Douglas Gregor87c30072010-07-26 04:08:02 +000029 (void)__builtin_offsetof(struct X0, a.b.c[4][5]);
30 return 0;
Reid Spencer5f016e22007-07-11 17:01:13 +000031}
Chris Lattner4c1a2a92007-11-13 20:50:37 +000032
33void test_sizeof(){
34 int arr[10];
Douglas Gregor87c30072010-07-26 04:08:02 +000035 (void)sizeof arr[0];
36 (void)sizeof(arr[0]);
37 (void)sizeof(arr)[0];
Chris Lattner4c1a2a92007-11-13 20:50:37 +000038}
39
Eli Friedmanadf077f2009-01-27 08:43:38 +000040// PR3418
41int test_leading_extension() {
Abramo Bagnarab9eb35c2010-10-15 07:51:18 +000042 __extension__ (*(char*)0) = 1; // expected-warning {{indirection of non-volatile null pointer}} \
43 // expected-note {{consider using __builtin_trap}}
Douglas Gregor87c30072010-07-26 04:08:02 +000044 return 0;
Eli Friedmanadf077f2009-01-27 08:43:38 +000045}
Chris Lattner4c1a2a92007-11-13 20:50:37 +000046
Chris Lattner1721a2d2009-04-13 00:10:38 +000047// PR3972
48int test5(int);
49int test6(void) {
50 return test5( // expected-note {{to match}}
51 test5(1)
52 ; // expected-error {{expected ')'}}
53}
John McCallb3c49062011-04-06 02:35:25 +000054
55// PR8394
56void test7() {
57 ({} // expected-note {{to match}}
58 ; // expected-error {{expected ')'}}
59}