OSDN Git Service

2004-05-20 H.J. Lu <hongjiu.lu@intel.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / sibcall-2.c
1 /* Simple check that sibling calls are performed from a
2    void non-leaf-function taking no arguments 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 (void);
15 extern void track (void);
16
17 int n = 0;
18 int main ()
19 {
20   recurser_void ();
21   exit (0);
22 }
23
24 void
25 recurser_void (void)
26 {
27   if (n == 0 || n == 7)
28     track ();
29
30   if (n == 10)
31     return;
32   n++;
33   recurser_void ();
34 }
35
36 void *trackpoint;
37
38 void
39 track ()
40 {
41   char stackpos[1];
42
43   if (n == 0)
44     trackpoint = stackpos;
45   else if (n != 7 || trackpoint != stackpos)
46     abort ();
47 }