From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 739983858404; Fri, 28 Oct 2022 17:44:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 739983858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666979064; bh=E76/vbAsYL+hetMXrHgfLgUNNURkFas+Ev3FK6lUHX0=; h=From:To:Subject:Date:From; b=h3JSTkpzYF1+cGwhL5byh2Ivtp6EcZElkvGVTLKNmDdTPrccj3rGuc/R8FsA/SSmI Bdy0vZUCgOTrAEjcanHZecjAgbxvMyk43XlRwj0cVbZyX+uRkzISgOK0vZW2U5zWek 8biLbloWiFN+Qy7AdCtMIcjSJJHtZdhxD88IwKXE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] libio: Handle -Wno-restrict with libc-diag.h X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 7a74ac2067c84776769fd2c1d992aab88d8a3eed X-Git-Newrev: a8e7af8af1036bf21a66e3d3fab00137b7a52970 Message-Id: <20221028174424.739983858404@sourceware.org> Date: Fri, 28 Oct 2022 17:44:22 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a8e7af8af1036bf21a66e3d3fab00137b7a52970 commit a8e7af8af1036bf21a66e3d3fab00137b7a52970 Author: Adhemerval Zanella Date: Thu Mar 24 16:14:56 2022 -0300 libio: Handle -Wno-restrict with libc-diag.h Diff: --- libio/Makefile | 4 ---- libio/tst-sprintf-ub.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libio/Makefile b/libio/Makefile index 64398ab1ee..7c91ebcec0 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -165,10 +165,6 @@ CFLAGS-iofputs_u.c += $(config-cflags-wno-ignored-attributes) CFLAGS-tst_putwc.c += -DOBJPFX=\"$(objpfx)\" -# These test cases intentionally use overlapping arguments -CFLAGS-tst-sprintf-ub.c += -Wno-restrict -CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict - LDFLAGS-tst-bz24228 = -Wl,--version-script=tst-bz24228.map tst_wprintf2-ARGS = "Some Text" diff --git a/libio/tst-sprintf-ub.c b/libio/tst-sprintf-ub.c index 55f341eadb..e6baa4fe6c 100644 --- a/libio/tst-sprintf-ub.c +++ b/libio/tst-sprintf-ub.c @@ -16,8 +16,14 @@ License along with the GNU C Library; if not, see . */ +#include #include +/* This is required to disable the overlap warnings for the fortify + test. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT_GCC (5, "-Wrestrict"); #include +DIAG_POP_NEEDS_COMMENT; #include #include @@ -54,7 +60,11 @@ do_one_test (int function, char *buf, ...) /* The regular sprintf and vsprintf functions do not override the destination buffer, even if source and destination overlap. */ case FUNCTION_SPRINTF: + /* This intentionally use overlapping arguments. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT_GCC (5, "-Wrestrict"); sprintf (buf, "%sCD", buf); + DIAG_POP_NEEDS_COMMENT; TEST_COMPARE_STRING (buf, expected); break; case FUNCTION_VSPRINTF: @@ -66,7 +76,11 @@ do_one_test (int function, char *buf, ...) /* On the other hand, snprint and vsnprint override overlapping source and destination buffers. */ case FUNCTION_SNPRINF: + /* This intentionally use overlapping arguments. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT_GCC (5, "-Wrestrict"); snprintf (buf, 3, "%sCD", buf); + DIAG_POP_NEEDS_COMMENT; TEST_COMPARE_STRING (buf, "CD"); break; case FUNCTION_VSNPRINTF: