1 // RUN: %clang_analyze_cc1 -fno-builtin -analyzer-checker=core,unix.Stream -verify %s
2 // RUN: %clang_analyze_cc1 -fno-builtin -analyzer-checker=core,alpha.unix.SimpleStream -verify %s
3
4 // expected-no-diagnostics
5
6 typedef struct _FILE FILE;
7
8 // These functions are not standard C library functions.
9 FILE *tmpfile(const char *restrict path); // Real 'tmpfile' should have exactly 0 formal parameters.
10 FILE *fopen(const char *restrict path); // Real 'fopen' should have exactly 2 formal parameters.
11 FILE *fdopen(int fd); // Real 'fdopen' should have exactly 2 formal parameters.
12
test_fopen_non_posix(void)13 void test_fopen_non_posix(void) {
14 FILE *fp = fopen("file"); // no-leak: This isn't the standard POSIX `fopen`, we don't know the semantics of this call.
15 }
16
test_tmpfile_non_posix(void)17 void test_tmpfile_non_posix(void) {
18 FILE *fp = tmpfile("file"); // no-leak: This isn't the standard POSIX `tmpfile`, we don't know the semantics of this call.
19 }
20
test_fdopen_non_posix(int fd)21 void test_fdopen_non_posix(int fd) {
22 FILE *fp = fdopen(fd); // no-leak: This isn't the standard POSIX `fdopen`, we don't know the semantics of this call.
23 }
24