Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2 | |
| 3 | void test1() { |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 4 | if (sizeof (int){ 1}) {} // sizeof compound literal |
| 5 | if (sizeof (int)) {} // sizeof type |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 6 | |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 7 | (void)(int)4; // cast. |
| 8 | (void)(int){4}; // compound literal. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 9 | |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 10 | int A = (struct{ int a;}){ 1}.a; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | int test2(int a, int b) { |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 14 | return a ? (void)a,b : a; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | int test3(int a, int b, int c) { |
| 18 | return a = b = c; |
| 19 | } |
| 20 | |
| 21 | int test4() { |
| 22 | test4(); |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 23 | return 0; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 24 | } |
| 25 | |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 26 | struct X0 { struct { struct { int c[10][9]; } b; } a; }; |
| 27 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 28 | int test_offsetof() { |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 29 | (void)__builtin_offsetof(struct X0, a.b.c[4][5]); |
| 30 | return 0; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 31 | } |
Chris Lattner | 4c1a2a9 | 2007-11-13 20:50:37 +0000 | [diff] [blame] | 32 | |
| 33 | void test_sizeof(){ |
| 34 | int arr[10]; |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 35 | (void)sizeof arr[0]; |
| 36 | (void)sizeof(arr[0]); |
| 37 | (void)sizeof(arr)[0]; |
Chris Lattner | 4c1a2a9 | 2007-11-13 20:50:37 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Eli Friedman | adf077f | 2009-01-27 08:43:38 +0000 | [diff] [blame] | 40 | // PR3418 |
| 41 | int test_leading_extension() { |
Abramo Bagnara | b9eb35c | 2010-10-15 07:51:18 +0000 | [diff] [blame] | 42 | __extension__ (*(char*)0) = 1; // expected-warning {{indirection of non-volatile null pointer}} \ |
| 43 | // expected-note {{consider using __builtin_trap}} |
Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 44 | return 0; |
Eli Friedman | adf077f | 2009-01-27 08:43:38 +0000 | [diff] [blame] | 45 | } |
Chris Lattner | 4c1a2a9 | 2007-11-13 20:50:37 +0000 | [diff] [blame] | 46 | |
Chris Lattner | 1721a2d | 2009-04-13 00:10:38 +0000 | [diff] [blame] | 47 | // PR3972 |
| 48 | int test5(int); |
| 49 | int test6(void) { |
| 50 | return test5( // expected-note {{to match}} |
| 51 | test5(1) |
| 52 | ; // expected-error {{expected ')'}} |
| 53 | } |
John McCall | b3c4906 | 2011-04-06 02:35:25 +0000 | [diff] [blame] | 54 | |
| 55 | // PR8394 |
| 56 | void test7() { |
| 57 | ({} // expected-note {{to match}} |
| 58 | ; // expected-error {{expected ')'}} |
| 59 | } |