From 0436426c7f7798b8eb4b48be9867495da8ef28f0 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 29 Dec 2017 23:32:13 -0500 Subject: Ignore warning about using different types of enums in switch When compiling with clang 6, I see a bunch of warnings like this: /home/emaisin/src/binutils-gdb/gdb/amd64-linux-tdep.c:1427:8: error: comparison of two values with different enumeration types in switch statement ('enum amd64_syscall' and 'amd 64_x32_syscall') [-Werror,-Wenum-compare-switch] case amd64_x32_sys_move_pages: ^~~~~~~~~~~~~~~~~~~~~~~~ In this switch, we indeed use enumerators of both types amd64_x32_syscall and amd64_syscall. This is done on purpose, and the enum values are chosen so that they are complementary. I think it's still a useful warning, so I chose to ignore just that particular case. gdb/ChangeLog: * common/diagnostics.h (DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES): New macro. * amd64-linux-tdep.c (amd64_canonicalize_syscall): Use it. --- gdb/common/diagnostics.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gdb/common') diff --git a/gdb/common/diagnostics.h b/gdb/common/diagnostics.h index d6ab6989165..30c0fd6172a 100644 --- a/gdb/common/diagnostics.h +++ b/gdb/common/diagnostics.h @@ -38,6 +38,8 @@ 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") #elif defined (__GNUC__) /* GCC */ @@ -45,12 +47,15 @@ # define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ DIAGNOSTIC_IGNORE ("-Wunused-function") +# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES #else /* Other compilers */ # define DIAGNOSTIC_IGNORE_SELF_MOVE # define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION +# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES + #endif #endif /* COMMON_DIAGNOSTICS_H */ -- cgit v1.2.1