1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 /* { dg-additional-sources "tailcall-8.c" } */
4
5 struct s { int x; };
6
7 int expected;
8 struct s *last_ptr;
9 struct s tmp;
10
11 void
start(int val,struct s * initial_last_ptr)12 start (int val, struct s *initial_last_ptr)
13 {
14 expected = val;
15 tmp.x = val;
16 last_ptr = initial_last_ptr;
17 }
18
19 void
f_direct(struct s param)20 f_direct (struct s param)
21 {
22 if (param.x != expected)
23 __builtin_abort ();
24 }
25
26 void
f_indirect(struct s * ptr)27 f_indirect (struct s *ptr)
28 {
29 if (ptr->x != expected)
30 __builtin_abort ();
31 last_ptr = ptr;
32 ptr->x += 100;
33 }
34
35 void
f_void(void)36 f_void (void)
37 {
38 if (last_ptr->x != expected + 100)
39 __builtin_abort ();
40 }
41
42
43 void g1 (struct s);
44 void g2 (struct s *);
45 void g3 (struct s *);
46 void g4 (struct s *);
47 void g5 (struct s);
48 void g6 (struct s);
49 void g7 (struct s);
50 void g8 (struct s *);
51 void g9 (struct s *);
52
53 int
main(void)54 main (void)
55 {
56 struct s g6_s = { 106 };
57
58 start (1, 0);
59 g1 (tmp);
60
61 start (2, 0);
62 g2 (&tmp);
63
64 start (3, 0);
65 g3 (&tmp);
66
67 start (4, 0);
68 g4 (&tmp);
69
70 start (5, 0);
71 g5 (tmp);
72
73 start (6, &g6_s);
74 g6 (tmp);
75
76 start (7, 0);
77 g7 (tmp);
78
79 start (8, 0);
80 g8 (&tmp);
81
82 start (9, 0);
83 g9 (&tmp);
84
85 return 0;
86 }
87