summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/sibcall-7.c
blob: 6d59ca3395fe7d3c0f647cd9718e5a04efe70a81 (plain)
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
/* Simple check that tail recursive call optimization is also
   controlled by -foptimize-sibling-calls.

   Copyright (C) 2006 Free Software Foundation Inc.
   Original test by Hans-Peter Nilsson  <hp@bitrange.com>  */

/* On IA64 the call frame is allocated on the register stack, not the
   normal stack.  */

/* { dg-do run { target { ! "ia64-*-*" } } } */
/* { dg-options "-O2 -fno-optimize-sibling-calls" } */


extern void abort (void);

extern void recurser_void (int);
extern void track (int);

int main (void)
{
  recurser_void (0);
  return 0;
}

void recurser_void (int n)
{
  if (n == 0 || n == 7)
    track (n);

  if (n == 10)
    return;

  recurser_void (n + 1);
}

void *trackpoint;

void track (int n)
{
  char stackpos[1];

  if (n == 0)
    trackpoint = stackpos;
  else if (n != 7 || trackpoint == stackpos)
    abort ();
}