1 /* PR middle-end/98664 - inconsistent --Wfree-nonheap-object for inlined
2 calls to system headers
4 { dg-options "-O2 -Wall" } */
6 # 7 "Wfree-nonheap-object-4.h" 1 3
13 static void f0 (struct A
*p
, void *q
) { p
->p
= q
; }
14 static void f1 (struct A
*p
, void *q
) { f0 (p
, q
); }
15 static void f2 (struct A
*p
, void *q
) { f1 (p
, q
); }
17 static void g0 (struct A
*p
)
19 __builtin_free (p
->p
); // { dg-warning "\\\[-Wfree-nonheap-object" }
22 static void g1 (struct A
*p
) { g0 (p
); }
23 static void g2 (struct A
*p
) { g1 (p
); }
25 # 26 "Wfree-nonheap-object-4.c"
27 #define NOIPA __attribute__ ((noipa))
29 extern int array
[]; // { dg-message "declared here" "note on line 29" }
31 /* Verify the warning is issued even for calls in a system header inlined
32 into a function outside the header. */
34 NOIPA
void warn_g0 (struct A
*p
)
42 // { dg-message "inlined from 'warn_g0'" "note on line 42" { target *-*-* } 0 }
45 /* Also verify the warning can be suppressed. */
47 NOIPA
void nowarn_g0 (struct A
*p
)
53 #pragma GCC diagnostic push
54 #pragma GCC diagnostic ignored "-Wfree-nonheap-object"
56 #pragma GCC diagnostic pop
60 NOIPA
void warn_g1 (struct A
*p
)
68 // { dg-message "inlined from 'g1'" "note on line 68" { target *-*-* } 0 }
69 // { dg-message "inlined from 'warn_g1'" "note on line 69" { target *-*-* } 0 }
72 NOIPA
void nowarn_g1 (struct A
*p
)
78 #pragma GCC diagnostic push
79 #pragma GCC diagnostic ignored "-Wfree-nonheap-object"
81 #pragma GCC diagnostic pop
85 NOIPA
void warn_g2 (struct A
*p
)
93 // { dg-message "inlined from 'g2'" "note on line 93" { target *-*-* } 0 }
94 // { dg-message "inlined from 'warn_g2'" "note on line 94" { target *-*-* } 0 }
97 NOIPA
void nowarn_g2 (struct A
*p
)
103 #pragma GCC diagnostic push
104 #pragma GCC diagnostic ignored "-Wfree-nonheap-object"
106 #pragma GCC diagnostic pop