| 1 |
/* Similar to Wfree-nonheap-object-5.c but with attribute artificial: |
| 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 "-O1 -Wall" } */ |
| 6 |
|
| 7 |
struct A |
| 8 |
{ |
| 9 |
void *p; |
| 10 |
}; |
| 11 |
|
| 12 |
__attribute__ ((always_inline, artificial)) |
| 13 |
inline void f0 (struct A *p) |
| 14 |
{ |
| 15 |
__builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" } |
| 16 |
} |
| 17 |
|
| 18 |
// Expect two instances of the text below: |
| 19 |
// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 } |
| 20 |
// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 } |
| 21 |
|
| 22 |
__attribute__ ((always_inline, artificial)) |
| 23 |
inline void f1 (struct A *p) { f0 (p); } |
| 24 |
__attribute__ ((always_inline, artificial)) |
| 25 |
inline void f2 (struct A *p) { f1 (p); } |
| 26 |
|
| 27 |
extern int array[]; |
| 28 |
// Also expect two instances of the note: |
| 29 |
// { dg-regexp "declared here" "first note for array" { target *-*-* } .-2 } |
| 30 |
// { dg-regexp "declared here" "second note for array" { target *-*-* } .-3 } |
| 31 |
|
| 32 |
void foo (struct A *p) |
| 33 |
{ |
| 34 |
p->p = array + 1; |
| 35 |
f0 (p); |
| 36 |
} |
| 37 |
|
| 38 |
// { dg-regexp " +inlined from 'foo' at \[^:\]+Wfree-nonheap-object-6.c:35:\\d+:" "inlined from foo" } |
| 39 |
|
| 40 |
|
| 41 |
void bar (struct A *p) |
| 42 |
{ |
| 43 |
p->p = array + 2; |
| 44 |
f2 (p); |
| 45 |
} |
| 46 |
|
| 47 |
// { dg-regexp " +inlined from 'f1' at \[^:\]+Wfree-nonheap-object-6.c:23:\\d+," "inlined from f1" } |
| 48 |
// { dg-regexp " +inlined from 'f2' at \[^:\]+Wfree-nonheap-object-6.c:25:\\d+," "inlined from f2" } |
| 49 |
// { dg-regexp " +inlined from 'bar' at \[^:\]+Wfree-nonheap-object-6.c:44:\\d+:" "inlined from bar" } |