gcc/testsuite/c-c++-common/analyzer/file-3.c
raw| 1 | typedef struct _IO_FILE FILE; |
| 2 | extern struct _IO_FILE *stderr; |
| 3 | |
| 4 | extern FILE *fopen (const char *__restrict __filename, |
| 5 | const char *__restrict __modes); |
| 6 | extern int _IO_getc (FILE *stream); |
| 7 | |
| 8 | void |
| 9 | test_1 (const char *path) |
| 10 | { |
| 11 | FILE *f = fopen (path, "r"); /* { dg-message "opened here" } */ |
| 12 | |
| 13 | /* Implementation of getc in glibc < 2.28. |
| 14 | Verify that we know that this doesn't close the file. */ |
| 15 | _IO_getc (f); |
| 16 | |
| 17 | return; /* { dg-warning "leak of FILE 'f'" } */ |
| 18 | } |