From a5b6e43669b78729d2ef78d668e19bac2b11197d Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Thu, 20 Oct 2022 09:32:06 +0000 Subject: [PATCH] gdb/unittests: PR28413, suppress warnings generated by Gnulib 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): 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. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28413 Approved-By: Simon Marchi Change-Id: Ieeb5a31a6902808d4c7263a2868ae19a35e0ccaa --- gdb/unittests/string_view-selftests.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c index 2d7261d18d3..86c8f6dc024 100644 --- a/gdb/unittests/string_view-selftests.c +++ b/gdb/unittests/string_view-selftests.c @@ -23,6 +23,15 @@ #define GNULIB_NAMESPACE gnulib +#include "diagnostics.h" + +/* Since this file uses GNULIB_NAMESPACE, some code defined in headers ends up + using system functions rather than gnulib replacements. This is not really + a problem for this test, but it generates some warnings with Clang, silence + them. */ +DIAGNOSTIC_PUSH +DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS + #include "defs.h" #include "gdbsupport/selftest.h" #include "gdbsupport/gdb_string_view.h" @@ -34,6 +43,8 @@ #include #include +DIAGNOSTIC_POP + /* libstdc++'s testsuite uses VERIFY. */ #define VERIFY SELF_CHECK -- 2.30.2