| 1 |
/* Similar to Wfree-nonheap-object-4.c but without system headers: |
| 2 |
verify that warnings for the same call site from distinct callers |
| 3 |
include the correct function names in the inlining stack. |
| 4 |
{ dg-do compile } |
| 5 |
{ dg-options "-O2 -Wall" } */ |
| 6 |
|
| 7 |
struct A |
| 8 |
{ |
| 9 |
void *p; |
| 10 |
}; |
| 11 |
|
| 12 |
static void f0 (struct A *p) |
| 13 |
{ |
| 14 |
__builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" } |
| 15 |
} |
| 16 |
|
| 17 |
// Expect two instances of the text below: |
| 18 |
// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 } |
| 19 |
// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 } |
| 20 |
|
| 21 |
static void f1 (struct A *p) { f0 (p); } |
| 22 |
static void f2 (struct A *p) { f1 (p); } |
| 23 |
|
| 24 |
extern int array[]; |
| 25 |
// Also expect two instances of the note: |
| 26 |
// { dg-regexp "declared here" "first note on line 24" { target *-*-* } .-2 } |
| 27 |
// { dg-regexp "declared here" "second note on line 24" { target *-*-* } .-3 } |
| 28 |
|
| 29 |
void foo (struct A *p) |
| 30 |
{ |
| 31 |
p->p = array + 1; |
| 32 |
f0 (p); |
| 33 |
} |
| 34 |
|
| 35 |
// { dg-regexp " +inlined from 'foo' at \[^:\]+Wfree-nonheap-object-5.c:32:\\d+:" "note on line 32" } |
| 36 |
|
| 37 |
|
| 38 |
void bar (struct A *p) |
| 39 |
{ |
| 40 |
p->p = array + 2; |
| 41 |
f2 (p); |
| 42 |
} |
| 43 |
|
| 44 |
// { dg-regexp " +inlined from 'f1' at \[^:\]+Wfree-nonheap-object-5.c:21:\\d+," "inlined from f1" } |
| 45 |
// { dg-regexp " +inlined from 'f2' at \[^:\]+Wfree-nonheap-object-5.c:22:\\d+," "inlined from f2" } |
| 46 |
// { dg-regexp " +inlined from 'bar' at \[^:\]+Wfree-nonheap-object-5.c:41:\\d+:" "inlined from bar" } |