public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Tsukasa OI <research_trasio@irq.a4lg.com>,
	Pedro Alves <pedro@palves.net>,
	Joel Brobecker <brobecker@adacore.com>,
	Enze Li <lienze@sourceware.org>
Cc: gdb-patches@sourceware.org, binutils@sourceware.org
Subject: [PATCH 1/4] include: Add macro to ignore -Wuser-defined-warnings
Date: Thu, 15 Sep 2022 03:10:23 +0000	[thread overview]
Message-ID: <5b9e49a21f757c68951b5b37c9008e22c0fd1271.1663211419.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <cover.1663211419.git.research_trasio@irq.a4lg.com>

User-defined warnings (on Clang, "-Wuser-defined-warnings") can be harmful
if we have specified "-Werror" and we have no control to disable the warning
ourself.  The particular example is Gnulib.

Gnulib generates a warning if the system version of certain functions
are used (to redirect the developer to use Gnulib version).  However,
it can be harmful if we cannot easily replace them (e.g. the target is in
the standard C++ library).

The new DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS macro can be helpful on such
cases.  A typical use of this macro is to place this macro before including
certain system headers.

include/ChangeLog:

	* diagnostics.h (DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS): New.
---
 include/diagnostics.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/diagnostics.h b/include/diagnostics.h
index 3da88282261..dbe6288d3d6 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -63,6 +63,11 @@
 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
   DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
 
+# if __has_warning ("-Wuser-defined-warnings")
+#  define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS \
+   DIAGNOSTIC_IGNORE ("-Wuser-defined-warnings")
+# endif
+
 # define DIAGNOSTIC_ERROR_SWITCH \
   DIAGNOSTIC_ERROR ("-Wswitch")
 
@@ -121,6 +126,10 @@
 # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
 #endif
 
+#ifndef DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
+# define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
+#endif
+
 #ifndef DIAGNOSTIC_ERROR_SWITCH
 # define DIAGNOSTIC_ERROR_SWITCH
 #endif
-- 
2.34.1


  reply	other threads:[~2022-09-15  3:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  3:10 [PATCH 0/4] gdb: (includes PR28413), Suppress some general warnings if built with Clang Tsukasa OI
2022-09-15  3:10 ` Tsukasa OI [this message]
2022-09-20 16:36   ` [PATCH 1/4] include: Add macro to ignore -Wuser-defined-warnings Nick Clifton
2022-09-21  6:13     ` Tsukasa OI
2022-09-22 13:02     ` Enze Li
2022-09-15  3:10 ` [PATCH 2/4] include: Add macro to ignore -Wunused-but-set-variable Tsukasa OI
2022-09-15  3:10 ` [PATCH 3/4] gdb/unittests: PR28413, suppress warnings generated by Gnulib Tsukasa OI
2022-09-15  3:10 ` [PATCH 4/4] gdb: Suppress "unused" variable warning on Clang Tsukasa OI
2022-09-22  8:25 ` [PATCH v2 0/4] gdb: (includes PR28413), Suppress some general warnings if built with Clang Tsukasa OI
2022-09-22  8:25   ` [PATCH v2 1/4] include: Add macro to ignore -Wuser-defined-warnings Tsukasa OI
2022-09-22 11:26     ` Nick Clifton
2022-09-22  8:25   ` [PATCH v2 2/4] include: Add macro to ignore -Wunused-but-set-variable Tsukasa OI
2022-09-22 11:27     ` Nick Clifton
2022-09-22  8:25   ` [PATCH v2 3/4] gdb/unittests: PR28413, suppress warnings generated by Gnulib Tsukasa OI
2022-10-18 13:44     ` Enze Li
2022-09-22  8:25   ` [PATCH v2 4/4] gdb: Suppress "unused" variable warning on Clang Tsukasa OI
2022-10-12 17:36     ` Simon Marchi

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=5b9e49a21f757c68951b5b37c9008e22c0fd1271.1663211419.git.research_trasio@irq.a4lg.com \
    --to=research_trasio@irq.a4lg.com \
    --cc=binutils@sourceware.org \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lienze@sourceware.org \
    --cc=pedro@palves.net \
    /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).