Testsuite: fix analyzer tests on Darwin

On macOS, system headers redefine by default some macros (memcpy,
memmove, etc) to checked versions, which defeats the analyzer. We
want to turn this off.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104042

gcc/testsuite/ChangeLog:

	PR analyzer/104042
	* gcc.dg/analyzer/analyzer.exp: Pass -D_FORTIFY_SOURCE=0 on Darwin.
	* gcc.dg/analyzer/fd-bind.c: Add missing <string.h> header.
	* gcc.dg/analyzer/fd-datagram-socket.c: Likewise.
	* gcc.dg/analyzer/fd-listen.c: Likewise.
	* gcc.dg/analyzer/fd-socket-misuse.c: Likewise.
	* gcc.dg/analyzer/fd-stream-socket-active-open.c: Likewise.
	* gcc.dg/analyzer/fd-stream-socket-passive-open.c: Likewise.
	* gcc.dg/analyzer/fd-stream-socket.c: Likewise.
	* gcc.dg/analyzer/fd-symbolic-socket.c: Likewise.
This commit is contained in:
Francois-Xavier Coudert 2023-08-19 23:22:06 +02:00
parent 70c50c8727
commit ce33bbfcbc
9 changed files with 16 additions and 0 deletions

View file

@ -32,6 +32,14 @@ if [info exists DEFAULT_CFLAGS] then {
# If a testcase doesn't have special options, use these.
set DEFAULT_CFLAGS "-fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries"
if { [istarget "*-*-darwin*" ] } {
# On macOS, system headers redefine by default some macros (memcpy,
# memmove, etc) to checked versions, which defeats the analyzer. We
# want to turn this off.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104042
set DEFAULT_CFLAGS "$DEFAULT_CFLAGS -D_FORTIFY_SOURCE=0"
}
# Initialize `dg'.
dg-init

View file

@ -1,6 +1,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

View file

@ -1,6 +1,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

View file

@ -1,6 +1,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

View file

@ -3,6 +3,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

View file

@ -1,6 +1,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

View file

@ -5,6 +5,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

View file

@ -1,6 +1,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

View file

@ -1,6 +1,7 @@
/* { dg-require-effective-target sockets } */
/* { dg-skip-if "" { powerpc*-*-aix* } } */
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>