| 1 |
/* PR middle-end/11151 */ |
| 2 |
/* Originator: Andrew Church <[email protected]> */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-xfail-run-if "PR36571 untyped return is char register" { "avr-*-*" } } */ |
| 5 |
/* { dg-require-effective-target untyped_assembly } */ |
| 6 |
/* This used to fail on SPARC because the (undefined) return |
| 7 |
value of 'bar' was overwriting that of 'foo'. */ |
| 8 |
|
| 9 |
extern void abort(void); |
| 10 |
|
| 11 |
int foo(int n) |
| 12 |
{ |
| 13 |
return n+1; |
| 14 |
} |
| 15 |
|
| 16 |
int bar(int n) |
| 17 |
{ |
| 18 |
__builtin_return(__builtin_apply((void (*)(void))foo, __builtin_apply_args(), 64)); |
| 19 |
} |
| 20 |
|
| 21 |
char *g; |
| 22 |
|
| 23 |
int main(void) |
| 24 |
{ |
| 25 |
/* Allocate 64 bytes on the stack to make sure that __builtin_apply |
| 26 |
can read at least 64 bytes above the return address. */ |
| 27 |
char dummy[64]; |
| 28 |
|
| 29 |
g = dummy; |
| 30 |
|
| 31 |
if (bar(1) != 2) |
| 32 |
abort(); |
| 33 |
|
| 34 |
return 0; |
| 35 |
} |