OSDN Git Service

2012-01-30 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / c1x-anon-struct-2.c
1 /* Test for anonymous structures and unions in C1X.  Test for invalid
2    cases.  */
3 /* { dg-do compile } */
4 /* { dg-options "-std=c1x -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 }