Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/fd-socket-meaning.c

raw
1 /* { dg-require-effective-target sockets } */
2
3 /* Needed on some targets until we have exception-handling working (PR 111475). */
4 /* { dg-additional-options "-fno-exceptions" } */
5
6 /* { dg-additional-options "-fanalyzer-verbose-state-changes" } */
7
8 #include <sys/socket.h>
9 #include <sys/un.h>
10 #include <unistd.h>
11 #include <errno.h>
12
13 void test_leak_unchecked_stream_socket (void)
14 {
15 int fd = socket (AF_UNIX, SOCK_STREAM, 0); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */
16 } /* { dg-warning "leak of file descriptor 'fd'" } */
17
18 void test_leak_unchecked_datagram_socket (void)
19 {
20 int fd = socket (AF_UNIX, SOCK_DGRAM, 0); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */
21 } /* { dg-warning "leak of file descriptor 'fd'" } */
22
23 void test_leak_unchecked_socket (int type)
24 {
25 int fd = socket (AF_UNIX, type, 0); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */
26 } /* { dg-warning "leak of file descriptor 'fd'" } */