[PATCH v2 3/4] gdb/unittests: PR28413, suppress warnings generated by Gnulib
Tsukasa OI
research_trasio@irq.a4lg.com
Thu Sep 22 08:25:46 GMT 2022
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 deal with 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 adding
DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS before including "defs.h".
gdb/ChangeLog:
pr 28413
* unittests/string_view-selftests.c: Suppress Gnulib-generated
warnings when "defs.h" is included.
---
gdb/unittests/string_view-selftests.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c
index 2d7261d18d3..c1f7799d94c 100644
--- a/gdb/unittests/string_view-selftests.c
+++ b/gdb/unittests/string_view-selftests.c
@@ -23,7 +23,12 @@
#define GNULIB_NAMESPACE gnulib
+#include "diagnostics.h"
+
+DIAGNOSTIC_PUSH
+DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
#include "defs.h"
+DIAGNOSTIC_POP
#include "gdbsupport/selftest.h"
#include "gdbsupport/gdb_string_view.h"
--
2.34.1
More information about the Gdb-patches
mailing list