2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / ext / anon-struct2.C
blob0c629ed482fda8530f28b33ac704d06701a8d38e
1 /* { dg-options "" } */
2 /* In GNU C++ mode, we recognize the anonymous struct extension,
3    but not Microsoft C extensions.  */
5 struct A { char a; };
7 struct B {
8   struct A;                     /* forward decl of B::A.  */
9   char b;
11 char testB[sizeof(B) == sizeof(A) ? 1 : -1];
13 struct C {
14   struct D { char d; };         /* decl of C::D.  */
15   char c;
17 char testC[sizeof(C) == sizeof(A) ? 1 : -1];
18 char testD[sizeof(C::D) == sizeof(A) ? 1 : -1];
20 /* GNU extension.  */
21 struct E {
22   struct { char z; };
23   char e;
25 char testE[sizeof(E) == 2 * sizeof(A) ? 1 : -1];
26 char testEz[sizeof( ((E *)0)->z )];
28 typedef struct A typedef_A;
29 struct F {
30   typedef_A;                    /* { dg-error "does not declare anything" } */
31   char f;
33 char testF[sizeof(F) == sizeof(A) ? 1 : -1];
35 /* Test that __extension__ does the right thing coming _from_ GNU C mode.  */
36 __extension__ struct G {
37   struct { char z; };
38   char g;
40 char testG[sizeof(G) == 2 * sizeof(A) ? 1 : -1];
42 struct H {
43   struct { char z; };
44   char h;
46 char testH[sizeof(H) == 2 * sizeof(A) ? 1 : -1];