Avoid expicit builtion list in tree-ssa-dce
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / fd-meaning.c
blob6a9ec921fd39c9005038af3f2408013aeb140f43
1 /* { dg-additional-options "-fanalyzer-verbose-state-changes" } */
2 int open(const char *, int mode);
3 void close(int fd);
5 #define O_RDONLY 0
6 #define O_WRONLY 1
7 #define O_RDWR 2
9 void test_1 (const char* path)
11 int fd = open (path, O_RDWR); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */
12 if (fd != -1)
14 close(fd); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */
15 close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */
19 void test_2 (const char* path)
21 int fd = open (path, O_RDONLY); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */
22 if (fd != -1)
24 close(fd); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */
25 close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */
29 void test_3 (const char* path)
31 int fd = open (path, O_WRONLY); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */
32 if (fd != -1)
34 close(fd); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */
35 close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */