* gcc.dg/ucnid-[23456].c: XFAIL on AIX.
[official-gcc.git] / gcc / testsuite / gcc.dg / sibcall-4.c
blob7237310b3a033d14728a3652e902b722bfdaac11
1 /* Simple check that sibling calls are performed from a
2 void non-leaf-function taking no arguments calling a function which
3 is about the same as itself.
5 Copyright (C) 2002 Free Software Foundation Inc.
6 Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
8 /* { dg-do run { xfail arc-*-* avr-*-* c4x-*-* cris-*-* h8300-*-* hppa*64*-*-* ip2k-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mn10300-*-* ns32k-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
9 /* { dg-options "-O2 -foptimize-sibling-calls" } */
11 /* The option -foptimize-sibling-calls is the default, but serves as
12 marker. This test is xfailed on targets without sibcall patterns
13 (except targets where the test does not work due to the return address
14 not saved on the regular stack). */
16 extern void abort (void);
17 extern void exit (int);
19 static void recurser_void1 (void);
20 static void recurser_void2 (void);
21 extern void track (void);
23 int n = 0;
24 int main ()
26 recurser_void1 ();
27 exit (0);
30 /* The functions should get the same stack-frame, and best way to make it
31 reasonably sure is to make them have the same contents (regarding the
32 n tests). */
34 static void __attribute__((noinline))
35 recurser_void1 (void)
37 if (n == 0 || n == 7 || n == 8)
38 track ();
40 if (n == 10)
41 return;
42 n++;
43 recurser_void2 ();
46 static void __attribute__((noinline))
47 recurser_void2 (void)
49 if (n == 0 || n == 7 || n == 8)
50 track ();
52 if (n == 10)
53 return;
54 n++;
55 recurser_void1 ();
58 void *trackpoint;
60 void
61 track ()
63 char stackpos[1];
65 if (n == 0)
66 trackpoint = stackpos;
67 else if ((n != 7 && n != 8) || trackpoint != stackpos)
68 abort ();