blob: 4fae368f3210ee4b0c1bedcd2394c3f939ac6dee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
int fprintf (FILE *, const char *, ...);
#define NULL ((void *)0)
void
test_1 (void)
{
int i;
for (i = 0; i < 2; ++i) {
FILE *fp = fopen ("/tmp/test", "w");
fprintf (fp, "hello:%s ", "world");
fclose (fp); /* { dg-bogus "double 'fclose'" } */
}
}
void
test_2 (void)
{
int i;
for (i = 0; i < 2; ++i) {
FILE *fp = fopen ("/tmp/test", "w");
fprintf (fp, "hello");
}
} /* { dg-warning "leak of FILE 'fp'" "" { xfail *-*-* } } */
/* TODO: fails on some targets due to fprintf call being optimized to
__builtin_fwrite with a size argument (idx 2) that fails
gimple_builtin_call_types_compatible_p, and thus the known_function
for __builtin_fwrite not being used (PR middle-end/108988). */
FILE *fp3;
void
test_3 (FILE **fpp)
{
int i;
for (i = 0; i < 2; ++i) {
*fpp = fopen ("/tmp/test", "w");
fprintf (*fpp, "hello");
fclose (*fpp); /* { dg-bogus "double 'fclose'" } */
*fpp = NULL;
}
}
|