1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/* { dg-do run } */
extern void exit (int) __attribute__ ((noreturn));
extern void abort (void) __attribute__ ((noreturn));
struct t
{
char dummy;
};
struct m
{
const struct t *t;
void (*m)(void);
};
struct s
{
const struct m *m;
void *o;
};
struct e
{
const struct t *t;
void *o;
};
struct ret
{
struct s s;
_Bool b;
};
const struct t t1 = { 1 };
const struct t t2 = { 2 };
const struct t t3 = { 3 };
const struct t t4 = { 4 };
const struct t t5 = { 5 };
void
pass (void)
{
exit (0);
}
void
fail (void)
{
abort ();
}
const struct m m1 = { &t4, fail };
const struct m m2 = { &t5, pass };
static struct e f2 (struct s s2, void *p);
static struct e f3 (struct s, void *) __attribute__ ((noinline));
static void f4 (struct s, void *) __attribute__ ((noinline));
struct ret c (struct s, const struct t *) __attribute__ ((noinline));
struct ret
c (struct s s1, const struct t *t)
{
struct ret r;
if (s1.m->t == t)
{
r.s.m = &m2;
r.s.o = s1.o;
r.b = 1;
}
else
{
r.s.m = 0;
r.s.o = 0;
r.b = 0;
}
return r;
}
void *m (void) __attribute__ ((noinline));
void *
m (void)
{
return 0;
}
struct e
f1 (struct s s1, void *p)
{
struct ret r;
void *a;
struct s a2;
r = c (s1, &t5);
if (r.b)
return f2 (r.s, p);
a = m ();
a2.m = &m1;
a2.o = a;
return f2 (a2, p);
}
static struct e
f2 (struct s s2, void *p)
{
struct e e1;
e1 = f3 (s2, p);
if (e1.t == &t2 && e1.o == 0)
{
e1.t = 0;
e1.o = 0;
}
return e1;
}
static struct e
f3 (struct s s1, void *p)
{
struct e r;
f4 (s1, p);
r.t = &t3;
r.o = 0;
return r;
}
struct s g1;
void *g2;
static void
f4 (struct s s1, void *p)
{
g1 = s1;
g2 = p;
s1.m->m ();
}
int
main ()
{
struct s s1;
s1.m = &m2;
s1.o = 0;
f1 (s1, 0);
abort ();
}
|