blob: df0b0071f759e47aa27c2a3aa4bc59f9b127d913 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/* Test C23 support for empty initializers: valid use cases. */
/* { dg-do run } */
/* { dg-options "-std=c23 -pedantic-errors" } */
extern void exit (int);
extern void abort (void);
struct s { int a; };
struct s s = {};
int x = {};
float y = {};
void *p = {};
union u { int a; long b; };
union u z = {};
int aa[2] = {};
void
f (int a)
{
volatile int vla[a] = {};
struct s as = {};
int ax = {};
float ay = {};
void *ap = {};
union u az = {};
int aaa[2] = {};
for (int i = 0; i < a; i++)
if (vla[i] != 0)
abort ();
if (as.a != 0)
abort ();
if (ax != 0)
abort ();
if (ay != 0)
abort ();
if (ap != 0)
abort ();
if (az.a != 0)
abort ();
if (aaa[0] != 0)
abort ();
if (aaa[1] != 0)
abort ();
if ((int) {} != 0)
abort ();
if ((float) {} != 0)
abort ();
if ((struct s) {}.a != 0)
abort ();
if ((union u) {}.a != 0)
abort ();
if ((int [5]) {}[2] != 0)
abort ();
/* Overwrite contents of vla before second call to make it more likely stack
contents are nonzero if proper initialization did not occur. */
for (int i = 0; i < a; i++)
vla[i] = -1;
}
int
main (void)
{
f (100);
f (100);
if (s.a != 0)
abort ();
if (x != 0)
abort ();
if (y != 0)
abort ();
if (p != 0)
abort ();
if (z.a != 0)
abort ();
if (aa[0] != 0)
abort ();
if (aa[1] != 0)
abort ();
exit (0);
}
|