The new analyzer tests for sockets are failing on embedded targets.
The newlib and avr-libc C libraries do not support sockets.
Testing done:
- No changes in gcc.sum for x86_64-pc-linux-gnu, with or without this
patch.
- Filtered cases are now UNSUPPORTED instead of failing on AVR and PRU
backends.
gcc/ChangeLog:
* doc/sourcebuild.texi (sockets): Document new check.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-accept.c: Require sockets.
* gcc.dg/analyzer/fd-bind.c: Ditto.
* gcc.dg/analyzer/fd-connect.c: Ditto.
* gcc.dg/analyzer/fd-datagram-socket.c: Ditto.
* gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c:
Ditto.
* gcc.dg/analyzer/fd-glibc-byte-stream-socket.c: Ditto.
* gcc.dg/analyzer/fd-glibc-datagram-client.c: Ditto.
* gcc.dg/analyzer/fd-glibc-datagram-socket.c: Ditto.
* gcc.dg/analyzer/fd-listen.c: Ditto.
* gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c: Ditto.
* gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c: Ditto.
* gcc.dg/analyzer/fd-socket-meaning.c: Ditto.
* gcc.dg/analyzer/fd-socket-misuse.c: Ditto.
* gcc.dg/analyzer/fd-stream-socket-active-open.c: Ditto.
* gcc.dg/analyzer/fd-stream-socket-passive-open.c: Ditto.
* gcc.dg/analyzer/fd-stream-socket.c: Ditto.
* gcc.dg/analyzer/fd-symbolic-socket.c: Ditto.
* lib/target-supports.exp (check_effective_target_sockets): New
check.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
@item pthread_h
Target has @code{pthread.h}.
+@item sockets
+Target can compile using @code{sys/socket.h} with no errors or warnings.
+
@item run_expensive_tests
Expensive testcases (usually those that consume excessive amounts of CPU
time) should be run on this target. This can be enabled by setting the
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
/* Example from glibc manual (16.9.7). */
+/* { dg-require-effective-target sockets } */
/* { dg-additional-options "-Wno-analyzer-too-complex" } */
#include <stdio.h>
/* Example from glibc manual (16.9.6). */
+/* { dg-require-effective-target sockets } */
#include <stdio.h>
#include <string.h>
/* Example from the glibc manual (16.10.4). */
+/* { dg-require-effective-target sockets } */
#include <stdio.h>
#include <errno.h>
/* Example from glibc manual (16.10.3). */
+/* { dg-require-effective-target sockets } */
#include <stdio.h>
#include <errno.h>
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
the source, must acknowledge the copyright and authors of this work.
*/
+/* { dg-require-effective-target sockets } */
/* { dg-additional-options "-Wno-analyzer-too-complex" } */
#include <sys/types.h>
the source, must acknowledge the copyright and authors of this work.
*/
+/* { dg-require-effective-target sockets } */
+
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
+/* { dg-require-effective-target sockets } */
/* { dg-additional-options "-fanalyzer-verbose-state-changes" } */
#include <sys/socket.h>
/* Various operations done on sockets in the wrong phase. */
+/* { dg-require-effective-target sockets } */
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
either from scratch, or when various phases are assumed to already
be done. */
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
+/* { dg-require-effective-target sockets } */
+
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
} "-pthread"]
}
+# Return 1 if the target supports both Unix and internet sockets, 0 otherwise.
+proc check_effective_target_sockets {} {
+ return [check_no_compiler_messages socket executable {
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+int main (void) {
+ socket(AF_UNIX, SOCK_STREAM, 0);
+ socket(AF_INET, SOCK_DGRAM, 0);
+ return 0;
+}
+ } ""]
+}
+
# Return 1 if compilation with -mpe-aligned-commons is error-free
# for trivial code, 0 otherwise.