PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on
[official-gcc.git] / gcc / testsuite / gcc.dg / anon-struct-11.c
blobc2f85fc24e43bcc5e32781a252045b3a222d3684
1 /* { dg-do compile } */
3 /* No special options--in particular, turn off the default
4 -pedantic-errors option. */
5 /* { dg-options "" } */
7 /* When not using -fplan9-extensions, we don't support automatic
8 conversion of pointer types, and we don't support referring to a
9 typedef name directly. */
11 extern void exit (int);
12 extern void abort (void);
14 struct A { char a; };
16 struct B {
17 char b;
18 struct A; /* { dg-warning "does not declare anything" } */
19 char c;
22 void
23 f1 (struct A *p) /* { dg-message "expected" } */
25 p->a = 1;
28 void
29 test1 (void)
31 struct B b;
32 struct A *p;
34 b.b = 2;
35 b.c = 3;
36 f1 (&b); /* { dg-warning "incompatible pointer type" } */
37 if (b.a != 1) /* { dg-error "no member" } */
38 abort ();
39 if (b.b != 2 || b.c != 3)
40 abort ();
41 p = &b; /* { dg-warning "incompatible pointer type" } */
42 if (p->a != 1)
43 abort ();
46 typedef struct { char d; } D;
48 struct E {
49 char b;
50 struct F { char f; }; /* { dg-warning "does not declare anything" } */
51 char c;
52 union {
53 D; /* { dg-warning "does not declare anything" } */
55 char e;
58 void
59 f2 (struct F *p) /* { dg-message "expected" } */
61 p->f = 6;
64 void
65 f3 (D *p) /* { dg-message "expected" } */
67 p->d = 4;
70 void
71 f4 (D d)
75 void
76 test2 (void)
78 struct E e;
79 struct F *pf;
80 D *pd;
81 D d;
83 e.b = 2;
84 e.c = 3;
85 e.e = 5;
86 f2 (&e); /* { dg-warning "incompatible pointer type" } */
87 f3 (&e); /* { dg-warning "incompatible pointer type" } */
88 if (e.d != 4) /* { dg-error "no member" } */
89 abort ();
90 if (e.f != 6) /* { dg-error "no member" } */
91 abort ();
92 if (e.b != 2 || e.c != 3 || e.e != 5)
93 abort ();
94 pf = &e; /* { dg-warning "incompatible pointer type" } */
95 if (pf->f != 6)
96 abort ();
97 pd = &e; /* { dg-warning "incompatible pointer type" } */
98 if (pd->d != 4)
99 abort ();
100 d = e.D; /* { dg-error "no member" } */
101 f3 (&e.D); /* { dg-error "no member" } */
102 f4 (e.D); /* { dg-error "no member" } */
106 main ()
108 test1 ();
109 test2 ();
110 exit (0);