Skip to content

Commit

Permalink
gdb/unittests: PR28413, suppress warnings generated by Gnulib
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
a4lg committed Nov 12, 2022
1 parent 7149607 commit 59c2393
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gdb/unittests/string_view-selftests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,6 +39,8 @@
#include <fstream>
#include <iostream>

DIAGNOSTIC_POP

/* libstdc++'s testsuite uses VERIFY. */
#define VERIFY SELF_CHECK

Expand Down

0 comments on commit 59c2393

Please sign in to comment.