1 /* Test for anonymous structures and unions in C11. Test for invalid
2 cases. */
3 /* { dg-do compile } */
4 /* { dg-options "-std=c11 -pedantic-errors" } */
5
6 typedef struct s0
7 {
8 int i;
9 } s0;
10
11 struct s1
12 {
13 int a;
14 struct s0; /* { dg-error "declaration does not declare anything" } */
15 };
16
17 struct s2
18 {
19 int a;
20 s0; /* { dg-error "declaration does not declare anything" } */
21 };
22
23 struct s3
24 {
25 struct
26 {
27 int i;
28 };
29 struct
30 {
31 int i; /* { dg-error "duplicate member" } */
32 };
33 };
34
35 struct s4
36 {
37 int a;
38 struct s
39 {
40 int i;
41 }; /* { dg-error "declaration does not declare anything" } */
42 };
43
44 struct s5
45 {
46 struct
47 {
48 int i;
49 } a;
50 int b;
51 } x;
52
53 void
54 f (void)
55 {
56 x.i = 0; /* { dg-error "has no member" } */
57 }