My patch
dwarf2read: Silence -Wenum-compare-switch warning
132448f835
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.
65 lines
2.1 KiB
C
65 lines
2.1 KiB
C
/* Copyright (C) 2017 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef COMMON_DIAGNOSTICS_H
|
|
#define COMMON_DIAGNOSTICS_H
|
|
|
|
#include "common/preprocessor.h"
|
|
|
|
#ifdef __GNUC__
|
|
# define DIAGNOSTIC_PUSH _Pragma ("GCC diagnostic push")
|
|
# define DIAGNOSTIC_POP _Pragma ("GCC diagnostic pop")
|
|
# define DIAGNOSTIC_IGNORE(option) \
|
|
_Pragma (STRINGIFY (GCC diagnostic ignored option))
|
|
#else
|
|
# define DIAGNOSTIC_PUSH
|
|
# define DIAGNOSTIC_POP
|
|
# define DIAGNOSTIC_IGNORE(option)
|
|
#endif
|
|
|
|
#if defined (__clang__) /* clang */
|
|
|
|
# define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
|
|
# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \
|
|
DIAGNOSTIC_IGNORE ("-Wdeprecated-register")
|
|
# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
|
|
DIAGNOSTIC_IGNORE ("-Wunused-function")
|
|
# 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
|
|
# 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 */
|