1/* { dg-do run } */
2/* { dg-options "-fplan9-extensions" } */
3
4/* When using -fplan9-extensions, we support automatic conversion of
5   pointer types, and we support referring to a typedef name
6   directly.  */
7
8extern void exit (int);
9extern void abort (void);
10
11struct A { char a; };
12
13struct B {
14  char b;
15  struct A;
16  char c;
17};
18
19void
20f1 (struct A *p)
21{
22  p->a = 1;
23}
24
25void
26test1 (void)
27{
28  struct B b;
29  struct A *p;
30
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 ();
41}
42
43typedef struct { char d; } D;
44
45struct E {
46  char b;
47  struct F { char f; };
48  char c;
49  union {
50    D;
51  };
52  char e;
53};
54
55void
56f2 (struct F *p)
57{
58  p->f = 6;
59}
60
61void
62f3 (D *p)
63{
64  p->d = 4;
65}
66
67void
68f4 (D d)
69{
70}
71
72void
73test2 (void)
74{
75  struct E e;
76  struct F *pf;
77  D *pd;
78  D d;
79
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);
100}
101
102int
103main ()
104{
105  test1 ();
106  test2 ();
107  exit (0);
108}
109