From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id AA6143888C4D; Thu, 12 May 2022 19:36:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA6143888C4D 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: 63397406220bb06a4ff7775a9ae234a6754dc586 X-Git-Newrev: 82999b9df2ef6932f77d0129120893cb959681c9 Message-Id: <20220512193618.AA6143888C4D@sourceware.org> Date: Thu, 12 May 2022 19:36:18 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 19:36:18 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=82999b9df2ef6932f77d0129120893cb959681c9 commit 82999b9df2ef6932f77d0129120893cb959681c9 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 3d26a0ed25..e614d6f934 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: