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 v2 2/4] include: Add macro to ignore -Wunused-but-set-variable
Date: Thu, 22 Sep 2022 08:25:45 +0000 [thread overview]
Message-ID: <6c1a2fe519fa913a0ad96e6debdec77ecdd9cdf6.1663835104.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <cover.1663835104.git.research_trasio@irq.a4lg.com>
"-Wunused-but-set-variable" warning option can be helpful to track variables
that are written but not read thereafter. But it can be harmful if some of
the code is auto-generated and we have no ways to deal with it.
The particular example is Bison-generated code.
The new DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE macro can be helpful on
such cases. A typical use of this macro is to place this macro before the
end of user prologues on Bison (.y) files.
include/ChangeLog:
* diagnostics.h (DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE): New.
---
include/diagnostics.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/diagnostics.h b/include/diagnostics.h
index dbe6288d3d6..4161dff6abc 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -68,6 +68,11 @@
DIAGNOSTIC_IGNORE ("-Wuser-defined-warnings")
# endif
+# if __has_warning ("-Wunused-but-set-variable")
+# define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE \
+ DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
+# endif
+
# define DIAGNOSTIC_ERROR_SWITCH \
DIAGNOSTIC_ERROR ("-Wswitch")
@@ -89,6 +94,11 @@
# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
+# if __GNUC__ >= 5
+# define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE \
+ DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
+# endif
+
/* GCC 4.8's "diagnostic push/pop" seems broken when using this, -Wswitch
remains enabled at the error level even after a pop. Therefore, don't
use it for GCC < 5. */
@@ -130,6 +140,10 @@
# define DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
#endif
+#ifndef DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
+# define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
+#endif
+
#ifndef DIAGNOSTIC_ERROR_SWITCH
# define DIAGNOSTIC_ERROR_SWITCH
#endif
--
2.34.1
next prev parent reply other threads:[~2022-09-22 8:26 UTC|newest]
Thread overview: 21+ 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 ` [PATCH 1/4] include: Add macro to ignore -Wuser-defined-warnings Tsukasa OI
2022-09-20 16:36 ` Nick Clifton
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 ` Tsukasa OI [this message]
2022-09-22 11:27 ` [PATCH v2 2/4] include: Add macro to ignore -Wunused-but-set-variable 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-10-18 16:14 ` Tsukasa OI
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
2022-10-16 13:37 ` Tsukasa OI
2022-10-17 12:35 ` Simon Marchi
2022-10-18 17:11 ` [PATCH v3] gdb/unittests: PR28413, suppress warnings generated by Gnulib Tsukasa OI
2022-11-14 14:02 ` 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=6c1a2fe519fa913a0ad96e6debdec77ecdd9cdf6.1663835104.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).