File: tailcall-7-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 (72 lines) | stat: -rw-r--r-- 1,417 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
/* { dg-do run { target trampolines } } */
/* { dg-options "-O2" } */
/* { dg-additional-sources "tailcall-7.c" } */

struct s { int x; };
extern struct s global;

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

struct s last;
struct s tmp;

struct s
f (int i)
{
  struct s ret;
  ret.x = i + 100;
  last = ret;
  return ret;
}

void
callit (void (*fn) (void))
{
  fn ();
}

int
test (int last_val, int global_val, int tmp_val)
{
  return last.x == last_val && global.x == global_val && tmp.x == tmp_val;
}

int
main (void)
{
  global.x = 200;
  tmp.x = 300;
  g1 ();
  if (!test (101, 200, 300))
    __builtin_abort ();
  g2 ();
  if (!test (102, 102, 300))
    __builtin_abort ();
  g3 (&tmp);
  if (!test (103, 102, 103))
    __builtin_abort ();
  if (g4 (tmp).x != 104 || !test (104, 102, 103))
    __builtin_abort ();
  if (g5 ().x != 105 || !test (105, 102, 103))
    __builtin_abort ();
  if (g6 ().x != 106 || !test (106, 102, 103))
    __builtin_abort ();
  if (g7 ().x != 107 || !test (107, 107, 103))
    __builtin_abort ();
  if (g8 (&tmp).x != 108 || !test (108, 107, 108))
    __builtin_abort ();
  if (g9 (tmp) != 9 || !test (109, 107, 108))
    __builtin_abort ();
  if (g10 (10) != 10 || !test (110, 107, 108))
    __builtin_abort ();
  return 0;
}