Steve Naroff | f009063 | 2007-09-02 02:04:30 +0000 | [diff] [blame] | 1 | // RUN: clang -parse-ast-check -pedantic %s |
| 2 | |
Steve Naroff | 6f9f307 | 2007-09-02 15:34:30 +0000 | [diff] [blame^] | 3 | static int x, y, z; |
| 4 | |
| 5 | static int ary[] = { x, y, z }; // expected-error{{initializer element is not constant}} |
| 6 | int ary2[] = { x, y, z }; // expected-error{{initializer element is not constant}} |
| 7 | |
| 8 | extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}} |
| 9 | |
Steve Naroff | f009063 | 2007-09-02 02:04:30 +0000 | [diff] [blame] | 10 | void func() { |
| 11 | int x = 1; |
| 12 | |
| 13 | //int x2[] = { 1, 3, 5 }; |
| 14 | |
| 15 | int x3[x] = { 1, 2 }; // gcc-error {{variable-sized object may not be initialized}} |
| 16 | |
| 17 | int x4 = { 1, 2 }; // gcc-warning {{excess elements in array initializer}} |
| 18 | |
| 19 | int y[4][3] = { |
| 20 | { 1, 3, 5 }, |
| 21 | { 2, 4, 6 }, |
| 22 | { 3, 5, 7 }, |
| 23 | }; |
| 24 | |
| 25 | int y2[4][3] = { |
| 26 | 1, 3, 5, 2, 4, 6, 3, 5, 7 |
| 27 | }; |
| 28 | |
| 29 | struct threeElements { |
| 30 | int a,b,c; |
| 31 | } z = { 1 }; |
| 32 | |
| 33 | struct threeElements *p = 7; // expected-warning{{incompatible types assigning 'int' to 'struct threeElements *'}} |
Steve Naroff | 6f9f307 | 2007-09-02 15:34:30 +0000 | [diff] [blame^] | 34 | |
| 35 | extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}} |
Steve Naroff | f009063 | 2007-09-02 02:04:30 +0000 | [diff] [blame] | 36 | } |