| 1 |
/* { dg-require-effective-target return_address } */ |
| 2 |
void abort (void); |
| 3 |
|
| 4 |
int check_fa_work (const char *, const char *) __attribute__((noinline,noipa)); |
| 5 |
int check_fa_mid (const char *) __attribute__((noinline,noipa)); |
| 6 |
int check_fa (char *) __attribute__((noinline,noipa)); |
| 7 |
int how_much (void) __attribute__((noinline,noipa)); |
| 8 |
|
| 9 |
int check_fa_work (const char *c, const char *f) |
| 10 |
{ |
| 11 |
const char d = 0; |
| 12 |
|
| 13 |
if (c >= &d) |
| 14 |
return c >= f && f >= &d; |
| 15 |
else |
| 16 |
return c <= f && f <= &d; |
| 17 |
} |
| 18 |
|
| 19 |
int check_fa_mid (const char *c) |
| 20 |
{ |
| 21 |
const char *f = __builtin_frame_address (0); |
| 22 |
|
| 23 |
/* Prevent a tail call to check_fa_work, eliding the current stack frame. */ |
| 24 |
return check_fa_work (c, f) != 0; |
| 25 |
} |
| 26 |
|
| 27 |
int check_fa (char *unused) |
| 28 |
{ |
| 29 |
const char c = 0; |
| 30 |
|
| 31 |
/* Prevent a tail call to check_fa_mid, eliding the current stack frame. */ |
| 32 |
return check_fa_mid (&c) != 0; |
| 33 |
} |
| 34 |
|
| 35 |
int how_much (void) |
| 36 |
{ |
| 37 |
return 8; |
| 38 |
} |
| 39 |
|
| 40 |
int main (void) |
| 41 |
{ |
| 42 |
char *unused = __builtin_alloca (how_much ()); |
| 43 |
|
| 44 |
if (!check_fa(unused)) |
| 45 |
abort(); |
| 46 |
return 0; |
| 47 |
} |