1 /* Simple check that tail recursive call optimization is also
2    controlled by -foptimize-sibling-calls.
3 
4    Copyright (C) 2006 Free Software Foundation Inc.
5    Original test by Hans-Peter Nilsson  <hp@bitrange.com>  */
6 
7 /* On IA64 the call frame is allocated on the register stack, not the
8    normal stack.  */
9 
10 /* { dg-do run { target { ! "ia64-*-*" } } } */
11 /* { dg-options "-O2 -fno-optimize-sibling-calls" } */
12 
13 
14 extern void abort (void);
15 
16 extern void recurser_void (int);
17 extern void track (int);
18 
main(void)19 int main (void)
20 {
21   recurser_void (0);
22   return 0;
23 }
24 
recurser_void(int n)25 void recurser_void (int n)
26 {
27   if (n == 0 || n == 7)
28     track (n);
29 
30   if (n == 10)
31     return;
32 
33   recurser_void (n + 1);
34 }
35 
36 void *trackpoint;
37 
track(int n)38 void track (int n)
39 {
40   char stackpos[1];
41 
42   if (n == 0)
43     trackpoint = stackpos;
44   else if (n != 7 || trackpoint == stackpos)
45     abort ();
46 }
47