gcc/testsuite/gcc.dg/Wuse-after-free-3.c
raw| 1 | /* PR middle-end/104232 - spurious -Wuse-after-free after conditional free |
| 2 | { dg-do compile } |
| 3 | { dg-options "-O2 -Wall" } */ |
| 4 | |
| 5 | char* f (void); |
| 6 | |
| 7 | static inline void freep (void *p) |
| 8 | { |
| 9 | __builtin_free (*(void**)p); // { dg-bogus "-Wuse-after-free" } |
| 10 | } |
| 11 | |
| 12 | int test_no_warn (void) |
| 13 | { |
| 14 | __attribute__ ((__cleanup__ (freep))) char *s = 0, *t = 0; |
| 15 | |
| 16 | t = f (); |
| 17 | if (!t) |
| 18 | return 0; |
| 19 | |
| 20 | s = f (); |
| 21 | return 1; |
| 22 | } |