svn merge -r102224:107263 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_4-branch
[official-gcc.git] / gcc / testsuite / gcc.dg / sibcall-2.c
blobcb2d1d599c69ae7a65f02e865b4d069360f2d268
1 /* Simple check that sibling calls are performed from a
2 void non-leaf-function taking no arguments calling itself.
4 Copyright (C) 2002 Free Software Foundation Inc.
5 Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
7 /* { dg-do run } */
8 /* { dg-options "-O2 -foptimize-sibling-calls" } */
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. */
14 extern void recurser_void (void);
15 extern void track (void);
17 int n = 0;
18 int main ()
20 recurser_void ();
21 exit (0);
24 void
25 recurser_void (void)
27 if (n == 0 || n == 7)
28 track ();
30 if (n == 10)
31 return;
32 n++;
33 recurser_void ();
36 void *trackpoint;
38 void
39 track ()
41 char stackpos[1];
43 if (n == 0)
44 trackpoint = stackpos;
45 else if (n != 7 || trackpoint != stackpos)
46 abort ();