PR ipa/61602
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr55305.c
blobfb61447151bbcc1254e513b29bc7428c0e7edb84
1 /* { dg-do run } */
3 extern void exit (int) __attribute__ ((noreturn));
4 extern void abort (void) __attribute__ ((noreturn));
6 struct t
8 char dummy;
9 };
11 struct m
13 const struct t *t;
14 void (*m)(void);
17 struct s
19 const struct m *m;
20 void *o;
23 struct e
25 const struct t *t;
26 void *o;
29 struct ret
31 struct s s;
32 _Bool b;
35 const struct t t1 = { 1 };
36 const struct t t2 = { 2 };
37 const struct t t3 = { 3 };
38 const struct t t4 = { 4 };
39 const struct t t5 = { 5 };
41 void
42 pass (void)
44 exit (0);
47 void
48 fail (void)
50 abort ();
53 const struct m m1 = { &t4, fail };
54 const struct m m2 = { &t5, pass };
56 static struct e f2 (struct s s2, void *p);
57 static struct e f3 (struct s, void *) __attribute__ ((noinline));
58 static void f4 (struct s, void *) __attribute__ ((noinline));
60 struct ret c (struct s, const struct t *) __attribute__ ((noinline));
62 struct ret
63 c (struct s s1, const struct t *t)
65 struct ret r;
67 if (s1.m->t == t)
69 r.s.m = &m2;
70 r.s.o = s1.o;
71 r.b = 1;
73 else
75 r.s.m = 0;
76 r.s.o = 0;
77 r.b = 0;
79 return r;
82 void *m (void) __attribute__ ((noinline));
84 void *
85 m (void)
87 return 0;
90 struct e
91 f1 (struct s s1, void *p)
93 struct ret r;
94 void *a;
95 struct s a2;
97 r = c (s1, &t5);
98 if (r.b)
99 return f2 (r.s, p);
100 a = m ();
101 a2.m = &m1;
102 a2.o = a;
103 return f2 (a2, p);
106 static struct e
107 f2 (struct s s2, void *p)
109 struct e e1;
111 e1 = f3 (s2, p);
112 if (e1.t == &t2 && e1.o == 0)
114 e1.t = 0;
115 e1.o = 0;
117 return e1;
120 static struct e
121 f3 (struct s s1, void *p)
123 struct e r;
125 f4 (s1, p);
126 r.t = &t3;
127 r.o = 0;
128 return r;
131 struct s g1;
132 void *g2;
134 static void
135 f4 (struct s s1, void *p)
137 g1 = s1;
138 g2 = p;
139 s1.m->m ();
143 main ()
145 struct s s1;
147 s1.m = &m2;
148 s1.o = 0;
149 f1 (s1, 0);
150 abort ();