aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/unix-fns.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/unix-fns.c')
-rw-r--r--test/Analysis/unix-fns.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c
new file mode 100644
index 0000000000..2bc2efa2d7
--- /dev/null
+++ b/test/Analysis/unix-fns.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=region
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic
+
+#include <fcntl.h>
+
+void test_open(const char *path) {
+ int fd;
+ fd = open(path, O_RDONLY); // no-warning
+ if (!fd)
+ close(fd);
+
+ fd = open(path, O_CREAT); // expected-warning{{Call to 'open' requires a third argument when the 'O_CREAT' flag is set}}
+ if (!fd)
+ close(fd);
+}