| 1 |
/* { dg-additional-options "-fanalyzer-verbosity=3" } */ |
| 2 |
|
| 3 |
typedef struct FILE FILE; |
| 4 |
|
| 5 |
FILE* fopen (const char*, const char*); |
| 6 |
int fclose (FILE*); |
| 7 |
|
| 8 |
extern int foo (); |
| 9 |
extern void bar (); |
| 10 |
|
| 11 |
void test (const char *path, int flag) |
| 12 |
{ |
| 13 |
FILE *fp = fopen (path, "r"); /* { dg-message "opened here" } */ |
| 14 |
|
| 15 |
/* We should report this control flow at -fanalyzer-verbosity=3. */ |
| 16 |
if (foo ()) /* { dg-message "branch" } */ |
| 17 |
bar (); |
| 18 |
else |
| 19 |
bar (); |
| 20 |
|
| 21 |
if (flag) /* { dg-message "when 'flag == 0'" } */ |
| 22 |
fclose (fp); |
| 23 |
} /* { dg-warning "leak of FILE 'fp'" } */ |