public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] libio: Handle -Wno-restrict with libc-diag.h Date: Thu, 31 Mar 2022 19:09:23 +0000 (GMT) [thread overview] Message-ID: <20220331190923.82EBF383943C@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a6b78fe83d0b92cc34417ad67f6c479f11f66619 commit a6b78fe83d0b92cc34417ad67f6c479f11f66619 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> 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 <https://www.gnu.org/licenses/>. */ +#include <libc-diag.h> #include <stdarg.h> +/* This is required to disable the overlap warnings for the fortify + test. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT_GCC (5, "-Wrestrict"); #include <stdio.h> +DIAG_POP_NEEDS_COMMENT; #include <string.h> #include <support/check.h> @@ -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:
next reply other threads:[~2022-03-31 19:09 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-31 19:09 Adhemerval Zanella [this message] -- strict thread matches above, loose matches on Subject: below -- 2023-02-09 19:51 Adhemerval Zanella 2022-10-28 17:44 Adhemerval Zanella 2022-10-04 13:02 Adhemerval Zanella 2022-06-09 21:22 Adhemerval Zanella 2022-06-09 13:19 Adhemerval Zanella 2022-06-03 14:08 Adhemerval Zanella 2022-05-13 14:22 Adhemerval Zanella 2022-05-12 19:36 Adhemerval Zanella 2022-05-10 18:26 Adhemerval Zanella 2022-04-29 14:06 Adhemerval Zanella 2022-04-04 12:57 Adhemerval Zanella 2022-03-29 20:32 Adhemerval Zanella
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220331190923.82EBF383943C@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).