| 1 |
/* PR middle-end/120608 */ |
| 2 |
/* { dg-do run { target musttail } } */ |
| 3 |
/* { dg-options "-O2 -fsanitize=address" } */ |
| 4 |
/* { dg-set-target-env-var ASAN_OPTIONS "detect_stack_use_after_return=1" } */ |
| 5 |
/* { dg-shouldfail "asan" } */ |
| 6 |
|
| 7 |
__attribute__((noipa)) void |
| 8 |
foo (int *x, int *y, int *z) |
| 9 |
{ |
| 10 |
++x[0]; |
| 11 |
++y[0]; |
| 12 |
++z[0]; |
| 13 |
} |
| 14 |
|
| 15 |
__attribute__((noipa)) void |
| 16 |
bar (int *x, int *y, int *z) |
| 17 |
{ |
| 18 |
volatile int a = x[0] + y[0] + z[0]; |
| 19 |
} |
| 20 |
|
| 21 |
__attribute__((noipa)) void |
| 22 |
baz (int *x, int *y, int *z) |
| 23 |
{ |
| 24 |
(void) x; (void) y; (void) z; |
| 25 |
int a = 42, b = -42, c = 0; |
| 26 |
foo (&a, &b, &c); |
| 27 |
[[gnu::musttail]] return bar (&a, &b, &c); /* { dg-warning "address of automatic variable 'a' passed to 'musttail' call argument" } */ |
| 28 |
} /* { dg-warning "address of automatic variable 'b' passed to 'musttail' call argument" "" { target *-*-* } .-1 } */ |
| 29 |
/* { dg-warning "address of automatic variable 'c' passed to 'musttail' call argument" "" { target *-*-* } .-2 } */ |
| 30 |
|
| 31 |
int |
| 32 |
main () |
| 33 |
{ |
| 34 |
baz (0, 0, 0); |
| 35 |
} |
| 36 |
|
| 37 |
// { dg-output "ERROR: AddressSanitizer: stack-use-after-return on address.*(\n|\r\n|\r)" } |
| 38 |
// { dg-output "READ of size .*" } |
| 39 |
// { dg-output ".*'a' \\(line 25\\) <== Memory access at offset \[0-9\]* is inside this variable.*" } |