From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 82DAC3858C39; Tue, 4 Oct 2022 13:02:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82DAC3858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664888528; bh=zCvSEWUdYPvTOHz9wDhMgJzkWPlqRTX1f4rm9XfgJlg=; h=From:To:Subject:Date:From; b=UWVny3x2YXFQnoqdA5XT2tdZhoeKHfesUQCdKfcHHQ1rUEvx81bQ656OHYCb3JcSF pYrxre0x0gyW+skRth2kFsJhmy62GRcusTMfKtBgYEpLFmHQUKOxjsu/eQimLn388M 5eu+p3uZn/HzOcJomXtQ5/Hj7PQzJIRsshjKuq+c= 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: 37e6bcc2fd095ea91c2cad87afbe4adea9274315 X-Git-Newrev: 1fdf898431043ad6fd1a0252b9b122a80130569a Message-Id: <20221004130208.82DAC3858C39@sourceware.org> Date: Tue, 4 Oct 2022 13:02:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1fdf898431043ad6fd1a0252b9b122a80130569a commit 1fdf898431043ad6fd1a0252b9b122a80130569a 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: