gcc/testsuite/gcc.dg/uninit-16.c
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-O2 -Wuninitialized" } */ |
| 3 | |
| 4 | int foo, bar; |
| 5 | |
| 6 | static |
| 7 | void decode_reloc(int reloc, int *is_alt) |
| 8 | { |
| 9 | if (reloc >= 20) |
| 10 | *is_alt = 1; |
| 11 | else if (reloc >= 10) |
| 12 | *is_alt = 0; |
| 13 | } |
| 14 | |
| 15 | void testfunc() |
| 16 | { |
| 17 | int alt_reloc; |
| 18 | |
| 19 | decode_reloc(foo, &alt_reloc); |
| 20 | |
| 21 | if (alt_reloc) /* { dg-warning "may be used uninitialized" } */ |
| 22 | bar = 42; |
| 23 | } |