Message ID | 8b99d666e78ba5b9d32c7889a2161c70b3da88df.1666258361.git.research_trasio@irq.a4lg.com |
---|---|
State | Superseded |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C93F63AAA076 for <patchwork@sourceware.org>; Thu, 20 Oct 2022 09:33:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C93F63AAA076 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666258428; bh=N64IVYqRs1KZ0jngodYFomJBw/rxpI0DP8JOnKm7jmI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ukTb03gNMk9ohlWQTgD587USkdMJ6Ifb7aH29HSXK7tr7GuZsGiw8BMJahXgnUSg+ lgvlMzzu4FsS3fU2SG96m+R59Lm6zOUOV7xgOUOvABz8jH6VevqvKxwhELFEWRYEJW zwa2gx6okPGjzpzArtHQXVrBAXxKwHbKeJ2ZUgnA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 13B8139494B3 for <gdb-patches@sourceware.org>; Thu, 20 Oct 2022 09:33:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 13B8139494B3 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 66F38300089; Thu, 20 Oct 2022 09:33:04 +0000 (UTC) To: Tsukasa OI <research_trasio@irq.a4lg.com>, Andrew Burgess <aburgess@redhat.com>, Mike Frysinger <vapier@gentoo.org>, Nick Clifton <nickc@redhat.com> Subject: [PATCH 01/40] gdb/unittests: PR28413, suppress warnings generated by Gnulib Date: Thu, 20 Oct 2022 09:32:06 +0000 Message-Id: <8b99d666e78ba5b9d32c7889a2161c70b3da88df.1666258361.git.research_trasio@irq.a4lg.com> In-Reply-To: <cover.1666258361.git.research_trasio@irq.a4lg.com> References: <cover.1666258361.git.research_trasio@irq.a4lg.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tsukasa OI via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tsukasa OI <research_trasio@irq.a4lg.com> Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
sim+gdb: Suppress warnings if built with Clang (big batch 1)
|
|
Commit Message
Tsukasa OI
Oct. 20, 2022, 9:32 a.m. UTC
Gnulib generates a warning if the system version of certain functions are used (to redirect the developer to use Gnulib version). It caused a compiler error when... - Compiled with Clang - -Werror is specified (by default) - C++ standard used by Clang is before C++17 (by default as of 15.0.0) when this unit test is activated. This issue is raised as PR28413. However, previous proposal to fix this issue (a "fix" to Gnulib): <https://lists.gnu.org/archive/html/bug-gnulib/2021-10/msg00003.html> was rejected because it ruins the intent of Gnulib warnings. So, we need a Binutils/GDB-side solution. This commit tries to address this issue on the GDB side. We have "include/diagnostics.h" to disable certain warnings only when necessary. This commit suppresses the Gnulib warnings by surrounding entire #include block with DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS to disable Gnulib- generated warnings on all standard C++ header files. --- gdb/unittests/string_view-selftests.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
On 10/20/22 05:32, Tsukasa OI via Gdb-patches wrote: > Gnulib generates a warning if the system version of certain functions > are used (to redirect the developer to use Gnulib version). It caused a > compiler error when... > > - Compiled with Clang > - -Werror is specified (by default) > - C++ standard used by Clang is before C++17 (by default as of 15.0.0) > when this unit test is activated. > > This issue is raised as PR28413. > > However, previous proposal to fix this issue (a "fix" to Gnulib): > <https://lists.gnu.org/archive/html/bug-gnulib/2021-10/msg00003.html> > was rejected because it ruins the intent of Gnulib warnings. > > So, we need a Binutils/GDB-side solution. > > This commit tries to address this issue on the GDB side. We have > "include/diagnostics.h" to disable certain warnings only when necessary. > > This commit suppresses the Gnulib warnings by surrounding entire #include > block with DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS to disable Gnulib- > generated warnings on all standard C++ header files. > --- > gdb/unittests/string_view-selftests.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c > index 2d7261d18d3..441d533b54e 100644 > --- a/gdb/unittests/string_view-selftests.c > +++ b/gdb/unittests/string_view-selftests.c > @@ -23,6 +23,11 @@ > > #define GNULIB_NAMESPACE gnulib > > +#include "diagnostics.h" > + > +DIAGNOSTIC_PUSH > +DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS > + > #include "defs.h" > #include "gdbsupport/selftest.h" > #include "gdbsupport/gdb_string_view.h" > @@ -34,6 +39,8 @@ > #include <fstream> > #include <iostream> > > +DIAGNOSTIC_POP > + > /* libstdc++'s testsuite uses VERIFY. */ > #define VERIFY SELF_CHECK > I think this is fine, so I went ahead and pushed it, after adding a little comment. I tried to look at an alternative way of fixing it, by making include/libiberty.h using GNULIB_NAMESPACE::free instead of free when GNULIB_NAMESPACE is defined. However, we then trip on: CXX unittests/string_view-selftests.o In file included from /home/smarchi/src/binutils-gdb/gdb/unittests/string_view-selftests.c:26: In file included from /home/smarchi/src/binutils-gdb/gdb/defs.h:28: In file included from /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/common-defs.h:204: In file included from /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/ptid.h:36: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/string:40: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/char_traits.h:40: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/postypes.h:40: /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/cwchar:231:12: error: The symbol ::wmemchr refers to the system function. Use gnulib::wmemchr instead. [-Werror,-Wuser-defined-warnings] { return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); } ^ And we can't fix that the same way... Simon
diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c index 2d7261d18d3..441d533b54e 100644 --- a/gdb/unittests/string_view-selftests.c +++ b/gdb/unittests/string_view-selftests.c @@ -23,6 +23,11 @@ #define GNULIB_NAMESPACE gnulib +#include "diagnostics.h" + +DIAGNOSTIC_PUSH +DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS + #include "defs.h" #include "gdbsupport/selftest.h" #include "gdbsupport/gdb_string_view.h" @@ -34,6 +39,8 @@ #include <fstream> #include <iostream> +DIAGNOSTIC_POP + /* libstdc++'s testsuite uses VERIFY. */ #define VERIFY SELF_CHECK