2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / anon-struct-2.c
blob4bd2d0f337c51463ff7306706c5d12e755ef29d1
1 /* { dg-options "-std=gnu89" } */
2 /* In GNU C mode, we recognize the anonymous struct/union extension,
3 but not Microsoft extensions. */
5 struct A { char a; };
7 /* MS extension. */
8 struct B {
9 struct A; /* { dg-warning "does not declare anything" } */
10 char b;
12 char testB[sizeof(struct B) == sizeof(struct A) ? 1 : -1];
14 /* MS extension. */
15 struct C {
16 struct D { char d; }; /* { dg-warning "does not declare anything" } */
17 char c;
19 char testC[sizeof(struct C) == sizeof(struct A) ? 1 : -1];
20 char testD[sizeof(struct D) == sizeof(struct A) ? 1 : -1];
22 /* GNU extension. */
23 struct E {
24 struct { char z; };
25 char e;
27 char testE[sizeof(struct E) == 2 * sizeof(struct A) ? 1 : -1];
29 /* MS extension. */
30 typedef struct A typedef_A;
31 struct F {
32 typedef_A; /* { dg-warning "does not declare anything" } */
33 char f;
35 char testF[sizeof(struct F) == sizeof(struct A) ? 1 : -1];
37 /* Test that __extension__ does the right thing coming _from_ GNU C mode. */
38 __extension__ struct G {
39 struct { char z; };
40 char g;
42 char testG[sizeof(struct G) == 2 * sizeof(struct A) ? 1 : -1];
44 struct H {
45 struct { char z; };
46 char h;
48 char testH[sizeof(struct H) == 2 * sizeof(struct A) ? 1 : -1];