analyzer: enable taint state machine by default [PR103533]
[official-gcc.git] / gcc / testsuite / c-c++-common / array-6.c
blobf3f2eda4ae7d63e6af239cf3a85002f11b0d1398
1 /* PR c/5597 */
2 /* { dg-do compile } */
3 /* { dg-options "" } */
5 /* Verify that GCC forbids non-static initialization of
6 flexible array members. */
8 struct str { int len; char s[]; };
10 struct str a = { 2, "a" };
12 void foo()
14 static struct str b = { 2, "b" };
15 struct str c = { 2, "c" }; /* { dg-error "(non-static)|(near initialization)" } */
16 struct str d = (struct str) { 2, "d" }; /* { dg-error "(non-static)|(near initialization)" } */
17 struct str e = (struct str) { d.len, "e" }; /* { dg-error "(non-static)|(initialization)" } */
20 struct str f = { 0, {} };
22 void bar()
24 static struct str g = { 0, {} };
25 struct str h = { 0, {} }; /* { dg-error "(non-static)|(near initialization)" } */
26 struct str i = (struct str) { 0, {} }; /* { dg-error "(non-static)|(near initialization)" } */
27 struct str j = (struct str) { i.len, {} }; /* { dg-error "(non-static)|(initialization)" } */
30 struct str k = { 0 };
32 void baz()
34 static struct str l = { 0 };
35 struct str m = { 0 };
36 struct str n = (struct str) { 0 };
37 struct str o = (struct str) { n.len };
40 struct str p = {};
42 void qux()
44 static struct str q = {};
45 struct str r = {};
46 struct str s = (struct str) {};