gcc/testsuite/gcc.dg/Wdangling-pointer-4.c
raw| 1 | /* PR middle-end/104761 - bogus -Wdangling-pointer with cleanup and infinite loop |
| 2 | { dg-do compile } |
| 3 | { dg-options "-O -Wall" } */ |
| 4 | |
| 5 | typedef struct { int i; } S; |
| 6 | |
| 7 | void f (S **); |
| 8 | |
| 9 | int g (int); |
| 10 | |
| 11 | void nowarn (int x) |
| 12 | { |
| 13 | S s = { 0 }; |
| 14 | |
| 15 | __attribute__((__cleanup__ (f))) S *p = 0; |
| 16 | |
| 17 | if (x) |
| 18 | { |
| 19 | g (s.i); // { dg-bogus "-Wdangling-pointer" } |
| 20 | for ( ; ; ); |
| 21 | } |
| 22 | } |