blob: 3ab2f4e5781cfa56d8f65f411eec592d368f30ad [file] [log] [blame]
Steve Narofff0090632007-09-02 02:04:30 +00001// RUN: clang -parse-ast-check -pedantic %s
2
Steve Naroff6f9f3072007-09-02 15:34:30 +00003static int x, y, z;
4
5static int ary[] = { x, y, z }; // expected-error{{initializer element is not constant}}
6int ary2[] = { x, y, z }; // expected-error{{initializer element is not constant}}
7
8extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}}
9
Steve Narofff0090632007-09-02 02:04:30 +000010void 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 Naroff6f9f3072007-09-02 15:34:30 +000034
35 extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
Steve Narofff0090632007-09-02 02:04:30 +000036}