| 1 |
/* Test C23 support for empty initializers: valid use cases with GNU |
| 2 |
extensions. */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-options "-std=gnu23" } */ |
| 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 |
} |