1 /* Simple check that sibling calls are performed from a
2    void non-leaf-function taking one int argument calling itself.
3 
4    Copyright (C) 2002 Free Software Foundation Inc.
5    Contributed by Hans-Peter Nilsson  <hp@bitrange.com>  */
6 
7 /* { dg-do run } */
8 /* { dg-options "-O2 -foptimize-sibling-calls" } */
9 
10 /* The option -foptimize-sibling-calls is the default, but serves as
11    marker.  Self-recursion tail calls are optimized for all targets,
12    regardless of presence of sibcall patterns.  */
13 
14 extern void recurser_void (int);
15 extern void track (int);
16 
17 int main ()
18 {
19   recurser_void (0);
20   exit (0);
21 }
22 
23 void
24 recurser_void (int n)
25 {
26   if (n == 0 || n == 7)
27     track (n);
28 
29   if (n == 10)
30     return;
31 
32   recurser_void (n + 1);
33 }
34 
35 void *trackpoint;
36 
37 void
38 track (int n)
39 {
40   char stackpos[1];
41 
42   if (n == 0)
43     trackpoint = stackpos;
44   else if (n != 7 || trackpoint != stackpos)
45     {
46       printf ("%d %p %p\n", n, trackpoint, stackpos);
47       abort ();
48     }
49 }
50