* [pushed] Only ignore -Wenum-compare-switch if it exists
@ 2017-12-31 4:34 Simon Marchi
0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2017-12-31 4:34 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
My patch
dwarf2read: Silence -Wenum-compare-switch warning
132448f8359a268f34f074b0908b5255b568da06
made some parts of dwarf2read.c ignore warnings about switch using enums
of different kinds. What I did not realize was that older Clang
versions (prior to 6) did not have that warning, and therefore give this
error:
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24187:7: error: unknown warning group '-Wenum-compare-switch', ignored [-Werror,-Wunknown-pragmas]
DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
^
/home/emaisin/src/binutils-gdb/gdb/common/diagnostics.h:42:3: note: expanded from macro 'DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES'
DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
^
/home/emaisin/src/binutils-gdb/gdb/common/diagnostics.h:27:3: note: expanded from macro 'DIAGNOSTIC_IGNORE'
_Pragma (STRINGIFY (GCC diagnostic ignored option))
^
<scratch space>:10:25: note: expanded from here
GCC diagnostic ignored "-Wenum-compare-switch"
^
Clang has a way to test if it knows about a particular warning. This
patch uses that feature to only define
DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES to something if the
warning is recognized by the Clang version being used. I tested
building dwarf2read.c with clang 4, 5, 6, as well as gcc.
gdb/ChangeLog:
* common/diagnostics.h
(DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES): Only
define if the compiler knows about -Wenum-compare-switch.
---
gdb/ChangeLog | 6 ++++++
gdb/common/diagnostics.h | 9 ++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7689e0e..edb3cd4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2017-12-30 Simon Marchi <simon.marchi@ericsson.com>
+ * common/diagnostics.h
+ (DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES): Only
+ define if the compiler knows about -Wenum-compare-switch.
+
+2017-12-30 Simon Marchi <simon.marchi@ericsson.com>
+
* dwarf2read.c (dwarf_decode_macro_bytes): Ignore
-Wenum-compare-switch warning.
(dwarf_decode_macros): Likewise.
diff --git a/gdb/common/diagnostics.h b/gdb/common/diagnostics.h
index 30c0fd6..c9ef6b6 100644
--- a/gdb/common/diagnostics.h
+++ b/gdb/common/diagnostics.h
@@ -38,9 +38,12 @@
DIAGNOSTIC_IGNORE ("-Wdeprecated-register")
# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
DIAGNOSTIC_IGNORE ("-Wunused-function")
-# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \
- DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
-
+# if __has_warning ("-Wenum-compare-switch")
+# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \
+ DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
+# else
+# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
+# endif
#elif defined (__GNUC__) /* GCC */
# define DIAGNOSTIC_IGNORE_SELF_MOVE
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-12-31 4:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-31 4:34 [pushed] Only ignore -Wenum-compare-switch if it exists Simon Marchi
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).