1 typedef struct FILE FILE;
2 FILE *fopen (const char *pathname
, const char *mode
);
3 #include "../../gcc.dg/analyzer/analyzer-decls.h"
6 test_passthrough (const char *pathname
, const char *mode
)
8 return fopen (pathname
, mode
);
12 test_null_pathname (const char *pathname
, const char *mode
)
14 return fopen (NULL
, mode
);
18 test_null_mode (const char *pathname
)
20 return fopen (pathname
, NULL
);
26 return fopen ("foo.txt", "r");
30 test_swapped_args (void)
32 return fopen ("r", "foo.txt"); /* TODO: would be nice to detect this. */
36 test_uninitialized_pathname (const char *mode
)
39 return fopen (buf
, mode
); /* { dg-warning "use of uninitialized value 'buf\\\[0\\\]'" } */
40 /* { dg-message "while looking for null terminator for argument 1 \\('&buf'\\) of 'fopen'..." "event" { target c } .-1 } */
41 /* { dg-message "while looking for null terminator for argument 1 \\('& buf'\\) of 'FILE\\* fopen\\(const char\\*, const char\\*\\)'..." "event" { target c++ } .-2 } */
45 test_uninitialized_mode (const char *filename
)
48 return fopen (filename
, buf
); /* { dg-warning "use of uninitialized value 'buf\\\[0\\\]'" } */
49 /* { dg-message "while looking for null terminator for argument 2 \\('&buf'\\) of 'fopen'..." "event" { target c } .-1 } */
50 /* { dg-message "while looking for null terminator for argument 2 \\('& buf'\\) of 'FILE\\* fopen\\(const char\\*, const char\\*\\)'..." "event" { target c++ } .-2 } */