Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / frame-address.c
blob109c2b229c82076252c6e938646f849bcd0f92ea
1 int check_fa_work (const char *, const char *) __attribute__((noinline));
2 int check_fa_mid (const char *) __attribute__((noinline));
3 int check_fa (char *) __attribute__((noinline));
4 int how_much (void) __attribute__((noinline));
6 int check_fa_work (const char *c, const char *f)
8 const char d = 0;
10 if (c >= &d)
11 return c >= f && f >= &d;
12 else
13 return c <= f && f <= &d;
16 int check_fa_mid (const char *c)
18 const char *f = __builtin_frame_address (0);
20 /* Prevent a tail call to check_fa_work, eliding the current stack frame. */
21 return check_fa_work (c, f) != 0;
24 int check_fa (char *unused)
26 const char c = 0;
28 /* Prevent a tail call to check_fa_mid, eliding the current stack frame. */
29 return check_fa_mid (&c) != 0;
32 int how_much (void)
34 return 8;
37 int main (void)
39 char *unused = __builtin_alloca (how_much ());
41 if (!check_fa(unused))
42 abort();
43 return 0;