File: tailcall-8-run.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (86 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download | duplicates (6)
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
/* { dg-do run } */
/* { dg-options "-O2" } */
/* { dg-additional-sources "tailcall-8.c" } */

struct s { int x; };

int expected;
struct s *last_ptr;
struct s tmp;

void
start (int val, struct s *initial_last_ptr)
{
  expected = val;
  tmp.x = val;
  last_ptr = initial_last_ptr;
}

void
f_direct (struct s param)
{
  if (param.x != expected)
    __builtin_abort ();
}

void
f_indirect (struct s *ptr)
{
  if (ptr->x != expected)
    __builtin_abort ();
  last_ptr = ptr;
  ptr->x += 100;
}

void
f_void (void)
{
  if (last_ptr->x != expected + 100)
    __builtin_abort ();
}


void g1 (struct s);
void g2 (struct s *);
void g3 (struct s *);
void g4 (struct s *);
void g5 (struct s);
void g6 (struct s);
void g7 (struct s);
void g8 (struct s *);
void g9 (struct s *);

int
main (void)
{
  struct s g6_s = { 106 };

  start (1, 0);
  g1 (tmp);

  start (2, 0);
  g2 (&tmp);

  start (3, 0);
  g3 (&tmp);

  start (4, 0);
  g4 (&tmp);

  start (5, 0);
  g5 (tmp);

  start (6, &g6_s);
  g6 (tmp);

  start (7, 0);
  g7 (tmp);

  start (8, 0);
  g8 (&tmp);

  start (9, 0);
  g9 (&tmp);

  return 0;
}