1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API -verify %s
8 #define NULL ((void*) 0)
11 int open(const char *, int, ...);
12 int close(int fildes
);
16 namespace MyNameSpace
{
17 int open(const char *a
, int b
, int c
, int d
);
20 void unix_open(const char *path
) {
22 fd
= open(path
, O_RDONLY
); // no-warning
27 void unix_open_misuse(const char *path
) {
30 fd
= open(path
, O_RDONLY
, mode
, NULL
); // expected-warning{{Call to 'open' with more than 3 arguments}}
35 // Don't treat open() in namespaces as the POSIX open()
36 void namespaced_open(const char *path
) {
37 MyNameSpace::open("Hi", 2, 3, 4); // no-warning
39 using namespace MyNameSpace
;
41 open("Hi", 2, 3, 4); // no-warning
45 fd
= ::open(path
, O_RDONLY
, mode
, NULL
); // expected-warning{{Call to 'open' with more than 3 arguments}}
52 static int open(const char *a
, int b
, int c
, int d
);
54 int open(int a
, int, int c
, int d
);
57 void class_qualified_open() {
58 MyClass::open("Hi", 2, 3, 4); // no-warning
61 mc
.open(1, 2, 3, 4); // no-warning