From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 2C970396E470; Fri, 13 May 2022 14:22:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C970396E470 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: 8e25a5af8c42a666bdea8ae6b8b38eb175dd1e2b X-Git-Newrev: d2db79f692e3e1d8f3fa4872b6e076513b84ba32 Message-Id: <20220513142234.2C970396E470@sourceware.org> Date: Fri, 13 May 2022 14:22:34 +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: Fri, 13 May 2022 14:22:34 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d2db79f692e3e1d8f3fa4872b6e076513b84ba32 commit d2db79f692e3e1d8f3fa4872b6e076513b84ba32 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: