gcc/testsuite/gcc.dg/analyzer/pr101875.c
raw| 1 | char * |
| 2 | fopen (const char *restrict, const char *restrict); |
| 3 | |
| 4 | void |
| 5 | err (void); |
| 6 | |
| 7 | void |
| 8 | k2_uninit (void) |
| 9 | { |
| 10 | char *setfiles[1]; |
| 11 | int i; /* { dg-message "region created on stack here" } */ |
| 12 | |
| 13 | setfiles[i] = fopen("", ""); /* { dg-warning "use of uninitialized value 'i'" } */ |
| 14 | if (!setfiles[i]) |
| 15 | err (); |
| 16 | } |
| 17 | |
| 18 | void |
| 19 | k2_leak (int i) |
| 20 | { |
| 21 | char *setfiles[1]; |
| 22 | |
| 23 | setfiles[i] = fopen("", ""); |
| 24 | if (!setfiles[i]) |
| 25 | err (); |
| 26 | } /* { dg-warning "leak of FILE" } */ |