1 /* { dg-additional-options "-fanalyzer-verbose-state-changes" } */
2 int open(const char *, int mode
);
9 void test_1 (const char* path
)
11 int fd
= open (path
, O_RDWR
); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */
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'\\}" } */
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'\\}" } */
34 close(fd
); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */
35 close(fd
); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */