public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb/unittests: PR28413, suppress warnings generated by Gnulib
Date: Mon, 14 Nov 2022 13:59:11 +0000 (GMT)	[thread overview]
Message-ID: <20221114135911.C83BD3948A4E@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a5b6e43669b78729d2ef78d668e19bac2b11197d

commit a5b6e43669b78729d2ef78d668e19bac2b11197d
Author: Tsukasa OI <research_trasio@irq.a4lg.com>
Date:   Thu Oct 20 09:32:06 2022 +0000

    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):
    <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.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28413
    Approved-By: Simon Marchi <simon.marchi@efficios.com>
    Change-Id: Ieeb5a31a6902808d4c7263a2868ae19a35e0ccaa

Diff:
---
 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 <fstream>
 #include <iostream>
 
+DIAGNOSTIC_POP
+
 /* libstdc++'s testsuite uses VERIFY.  */
 #define VERIFY SELF_CHECK

                 reply	other threads:[~2022-11-14 13:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221114135911.C83BD3948A4E@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-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: link
Be 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).