blob: ffc5c83a0a73be7b3d5a8e606fe61ce31cdaec77 [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() {
42 __extension__ (*(char*)0) = 1;
Douglas Gregor87c30072010-07-26 04:08:02 +000043 return 0;
Eli Friedmanadf077f2009-01-27 08:43:38 +000044}
Chris Lattner4c1a2a92007-11-13 20:50:37 +000045
Chris Lattner1721a2d2009-04-13 00:10:38 +000046// PR3972
47int test5(int);
48int test6(void) {
49 return test5( // expected-note {{to match}}
50 test5(1)
51 ; // expected-error {{expected ')'}}
52}