builtin-has-attribute-4.c: Skip on 32-bit hppa*-*-hpux*.
[official-gcc.git] / gcc / testsuite / gcc.dg / anon-struct-12.c
blob60cd178224ed81fb4df971d478f3b4a4c0bb59f7
1 /* { dg-do run } */
2 /* { dg-options "-fplan9-extensions" } */
4 /* When using -fplan9-extensions, we support automatic conversion of
5 pointer types, and we support referring to a typedef name
6 directly. */
8 extern void exit (int);
9 extern void abort (void);
11 struct A { char a; };
13 struct B {
14 char b;
15 struct A;
16 char c;
19 void
20 f1 (struct A *p)
22 p->a = 1;
25 void
26 test1 (void)
28 struct B b;
29 struct A *p;
31 b.b = 2;
32 b.c = 3;
33 f1 (&b);
34 if (b.a != 1)
35 abort ();
36 if (b.b != 2 || b.c != 3)
37 abort ();
38 p = &b;
39 if (p->a != 1)
40 abort ();
43 typedef struct { char d; } D;
45 struct E {
46 char b;
47 struct F { char f; };
48 char c;
49 union {
52 char e;
55 void
56 f2 (struct F *p)
58 p->f = 6;
61 void
62 f3 (D *p)
64 p->d = 4;
67 void
68 f4 (D d)
72 void
73 test2 (void)
75 struct E e;
76 struct F *pf;
77 D *pd;
78 D d;
80 e.b = 2;
81 e.c = 3;
82 e.e = 5;
83 f2 (&e);
84 f3 (&e);
85 if (e.d != 4)
86 abort ();
87 if (e.f != 6)
88 abort ();
89 if (e.b != 2 || e.c != 3 || e.e != 5)
90 abort ();
91 pf = &e;
92 if (pf->f != 6)
93 abort ();
94 pd = &e;
95 if (pd->d != 4)
96 abort ();
97 d = e.D;
98 f3 (&e.D);
99 f4 (e.D);
103 main ()
105 test1 ();
106 test2 ();
107 exit (0);