ASAN: emit line information of stack variables.
[platform/upstream/linaro-gcc.git] / gcc / testsuite / c-c++-common / asan / pr64820.c
1 /* { dg-do run } */
2 /* { dg-require-effective-target fstack_protector } */
3 /* { dg-options "-fstack-protector-strong" } */
4 /* { dg-set-target-env-var ASAN_OPTIONS "detect_stack_use_after_return=1" } */
5 /* { dg-shouldfail "asan" } */
6
7 __attribute__((noinline))
8 char *Ident(char *x) {
9   return x;
10 }
11
12 __attribute__((noinline))
13 char *Func1() {
14   char local[1 << 12];
15   return Ident(local);
16 }
17
18 __attribute__((noinline))
19 void Func2(char *x) {
20   *x = 1;
21 }
22 int main(int argc, char **argv) {
23   Func2(Func1());
24   return 0;
25 }
26
27 /* { dg-output "AddressSanitizer: stack-use-after-return on address 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
28 /* { dg-output "\[^\n\r]*WRITE of size 1 at .* thread T0.*" } */
29 /* { dg-output "    #0.*(Func2)?.*pr64820.(c:21)?.*" } */
30 /* { dg-output "is located in stack of thread T0 at offset.*" } */
31 /* { dg-output "\'local\'\[^\n\r]* \\(line 14\\) <== Memory access at offset 32 is inside this variable" } */