unix-fns.c revision fc89323210a5f3f53808f7d801705d6b8c0a4224
1// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=region
2// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic
3
4#ifndef O_CREAT
5#define O_CREAT 0x0200
6#define O_RDONLY 0x0000
7#endif
8int open(const char *, int, ...);
9
10void test_open(const char *path) {
11  int fd;
12  fd = open(path, O_RDONLY); // no-warning
13  if (!fd)
14    close(fd);
15
16  fd = open(path, O_CREAT); // expected-warning{{Call to 'open' requires a third argument when the 'O_CREAT' flag is set}}
17  if (!fd)
18    close(fd);
19}
20