1 typedef struct FILE FILE;
2
3 FILE* fopen (const char*, const char*);
4 int fclose (FILE*);
5
6 struct foo
7 {
8 FILE *m_f;
9 };
10
11 void test (const char *path)
12 {
13 struct foo f;
14 f.m_f = fopen (path, "r");
15
16 if (!f.m_f)
17 return; /* { dg-bogus "leak of FILE" } */
18
19 fclose (f.m_f);
20 fclose (f.m_f); /* { dg-warning "double 'fclose' of FILE 'f.m_f'" } */
21 }
22
23 /* Swallow -Wuse-after-free issued for the same problem
24 { dg-prune-output "-Wuse-after-free" } */