Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -parse-noop -verify %s |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2 | |
| 3 | void test1() { |
| 4 | if (sizeof (int){ 1}); // sizeof compound literal |
| 5 | if (sizeof (int)); // sizeof type |
| 6 | |
| 7 | (int)4; // cast. |
Chris Lattner | e45fa6a | 2007-08-25 05:31:19 +0000 | [diff] [blame] | 8 | (int){4}; // compound literal. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 9 | |
| 10 | // FIXME: change this to the struct version when we can. |
| 11 | //int A = (struct{ int a;}){ 1}.a; |
| 12 | int A = (int){ 1}.a; |
| 13 | } |
| 14 | |
| 15 | int test2(int a, int b) { |
| 16 | return a ? a,b : a; |
| 17 | } |
| 18 | |
| 19 | int test3(int a, int b, int c) { |
| 20 | return a = b = c; |
| 21 | } |
| 22 | |
| 23 | int test4() { |
| 24 | test4(); |
| 25 | } |
| 26 | |
| 27 | int test_offsetof() { |
| 28 | // FIXME: change into something that is semantically correct. |
| 29 | __builtin_offsetof(int, a.b.c[4][5]); |
| 30 | } |
Chris Lattner | 4c1a2a9 | 2007-11-13 20:50:37 +0000 | [diff] [blame] | 31 | |
| 32 | void test_sizeof(){ |
| 33 | int arr[10]; |
| 34 | sizeof arr[0]; |
| 35 | sizeof(arr[0]); |
| 36 | sizeof(arr)[0]; |
| 37 | } |
| 38 | |
Eli Friedman | adf077f | 2009-01-27 08:43:38 +0000 | [diff] [blame] | 39 | // PR3418 |
| 40 | int test_leading_extension() { |
| 41 | __extension__ (*(char*)0) = 1; |
| 42 | } |
Chris Lattner | 4c1a2a9 | 2007-11-13 20:50:37 +0000 | [diff] [blame] | 43 | |
Chris Lattner | 1721a2d | 2009-04-13 00:10:38 +0000 | [diff] [blame] | 44 | // PR3972 |
| 45 | int test5(int); |
| 46 | int test6(void) { |
| 47 | return test5( // expected-note {{to match}} |
| 48 | test5(1) |
| 49 | ; // expected-error {{expected ')'}} |
| 50 | } |