1 // RUN: %clang_analyze_cc1 -verify -analyzer-checker=core,unix.API -analyzer-output=text %s
3 // Verify that the UnixAPIChecker finds the missing mode value regardless
4 // of the particular values of these macros, particularly O_CREAT.
5 #define O_RDONLY 0x2000
6 #define O_WRONLY 0x8000
9 extern int open(const char *path
, int flags
, ...);
11 void missing_mode_1(const char *path
) {
12 (void)open(path
, O_CREAT
); // expected-warning{{Call to 'open' requires a 3rd argument when the 'O_CREAT' flag is set}} \
13 expected
-note
{{Call to
'open' requires a
3rd argument when the
'O_CREAT' flag is set
}}
18 void missing_mode_2(const char *path
) {
20 if (some_flag
) { // expected-note {{Assuming 'some_flag' is not equal to 0}} \
21 expected
-note
{{Taking
true branch
}}
24 (void)open(path
, mode
); // expected-warning{{Call to 'open' requires a 3rd argument when the 'O_CREAT' flag is set}} \
25 expected
-note
{{Call to
'open' requires a
3rd argument when the
'O_CREAT' flag is set
}}
28 void no_creat(const char* path
) {
30 (void)open(path
, mode
); // ok
33 void mode_is_there(const char *path
) {
38 (void)open(path
, mode
, 0770); // ok