xref: /llvm-project/clang/test/Analysis/stream-non-posix-function.c (revision 09f160c6298255f520b379b88161fbd1c365b308)
1*09f160c6SBalázs Kéri // RUN: %clang_analyze_cc1 -fno-builtin -analyzer-checker=core,unix.Stream -verify %s
20f7f8dbcSBen Shi // RUN: %clang_analyze_cc1 -fno-builtin -analyzer-checker=core,alpha.unix.SimpleStream -verify %s
30f7f8dbcSBen Shi 
432521bb3SBen Shi // expected-no-diagnostics
532521bb3SBen Shi 
632521bb3SBen Shi typedef struct _FILE FILE;
732521bb3SBen Shi 
832521bb3SBen Shi // These functions are not standard C library functions.
932521bb3SBen Shi FILE *tmpfile(const char *restrict path); // Real 'tmpfile' should have exactly 0 formal parameters.
1032521bb3SBen Shi FILE *fopen(const char *restrict path);   // Real 'fopen' should have exactly 2 formal parameters.
1118c0f59bSBen Shi FILE *fdopen(int fd);                     // Real 'fdopen' should have exactly 2 formal parameters.
1232521bb3SBen Shi 
test_fopen_non_posix(void)1332521bb3SBen Shi void test_fopen_non_posix(void) {
1432521bb3SBen Shi   FILE *fp = fopen("file"); // no-leak: This isn't the standard POSIX `fopen`, we don't know the semantics of this call.
1532521bb3SBen Shi }
1632521bb3SBen Shi 
test_tmpfile_non_posix(void)1732521bb3SBen Shi void test_tmpfile_non_posix(void) {
1818c0f59bSBen Shi   FILE *fp = tmpfile("file"); // no-leak: This isn't the standard POSIX `tmpfile`, we don't know the semantics of this call.
1918c0f59bSBen Shi }
2018c0f59bSBen Shi 
test_fdopen_non_posix(int fd)2118c0f59bSBen Shi void test_fdopen_non_posix(int fd) {
2218c0f59bSBen Shi   FILE *fp = fdopen(fd); // no-leak: This isn't the standard POSIX `fdopen`, we don't know the semantics of this call.
2332521bb3SBen Shi }
24