]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/gnu2x-empty-init-1.c
c: Support C2x empty initializer braces
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / gnu2x-empty-init-1.c
1 /* Test C2X support for empty initializers: valid use cases with GNU
2 extensions. */
3 /* { dg-do run } */
4 /* { dg-options "-std=gnu2x" } */
5
6 extern void exit (int);
7 extern void abort (void);
8
9 void
10 f (int a)
11 {
12 struct s { volatile int x[a]; };
13 struct s b = {};
14 for (int i = 0; i < a; i++)
15 if (b.x[i] != 0)
16 abort ();
17 /* Overwrite contents of b.x before second call to make it more likely stack
18 contents are nonzero if proper initialization did not occur. */
19 for (int i = 0; i < a; i++)
20 b.x[i] = -1;
21 }
22
23 int
24 main (void)
25 {
26 f (100);
27 f (100);
28 exit (0);
29 }