Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/pr101188.c

raw
1 /* { dg-require-effective-target indirect_calls } */
2 typedef __UINT8_TYPE__ uint8_t;
3 typedef __UINT16_TYPE__ uint16_t;
4
5 typedef uint8_t (*fn1)(void *a);
6 typedef void (*fn2)(void *a, int *arg);
7
8 struct S
9 {
10 uint8_t buffer[64];
11 uint16_t n;
12 fn2 f2;
13 void *a;
14 fn1 f1;
15 };
16
17 volatile uint16_t x;
18
19 void __attribute__((__noinline__,__noclone__))
20 foo (uint16_t n)
21 {
22 x = n;
23 }
24
25 void __attribute__((__noinline__,__noclone__))
26 testfn (struct S *self)
27 {
28 int arg;
29
30 foo (self->n);
31 self->n++;
32 self->f2 (self->a, &arg);
33 self->buffer[0] = self->f1 (self->a);
34 }
35
36 static unsigned char myfn2_called = 0;
37
38 static void
39 myfn2 (void *a, int *arg)
40 {
41 myfn2_called = 1;
42 }
43
44 static uint8_t
45 myfn1 (void *a)
46 {
47 return 0;
48 }
49
50 int main (void)
51 {
52 struct S s;
53 s.n = 0;
54 s.f2 = myfn2;
55 s.f1 = myfn1;
56 testfn (&s);
57 if (myfn2_called != 1)
58 __builtin_abort();
59 return 0;
60 }
61