started collecting some parser tests
[cparser] / parsetest / initializers.c
1 int bla = 1;
2 int bla2 = 2;
3 int bla3 = { 3 };
4 int bla4 = { 4, };
5 /* should fail:
6 int bla5 = { { 2 } };
7 int bla6 = { 1, 2 };
8 int *bla7 = { 2, };
9 int bla5 = 1, ;
10 */
11
12 char str1[] = "Hello";
13 char str2[5] = "Hello";
14 char str3[10] = "Hello";
15 signed char str4[] = "Hello";
16 unsigned char str5[] = "Hello";
17 /* char str4[4] = "Hello"; unclear wether this should be an error or warning
18  * gcc produces a warning, icc an error */
19
20 struct foo {
21         int a, b;
22 };
23
24 struct foo f1 = { 1, 2 };
25 struct foo f2 = { { 1, }, 2 }; /* produces a warning on icc and gcc... */
26 struct foo f3 = { { { 1, } }, 2 }; /* produces a warning on icc and gcc... */
27
28 struct foob {
29         int a;
30         struct foobb {
31                 float c, d;
32         };
33         int e;
34 };
35
36 struct foob ff2 = { 1, 2.5, 4, 2 };
37
38 union foou {
39         int a;
40         float b;
41 };
42
43 union foou g1 = { 5 };