From 9cc62d333a83bee08ca7917b68f0cfa10fda7816 Mon Sep 17 00:00:00 2001 From: yanyir Date: Sun, 1 Sep 2024 04:46:59 +0800 Subject: [PATCH] gdb: fix clang integer value -1 outside valid range error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport gdb patch to fix the "integer value -1 is outside the valid range of values" errors when building with clang 16+. Without the patch, when using clang 16 to build, we get some errors like: In file included from cp-valprint.c:20: In file included from ./defs.h:65: ./../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag' [-Wenum-constexpr-conversion] 85 | integer_for_size(T (-1) < T (0))>::type | ^ ^ GDB ignore -Wenum-constexpr-conversion around enum-flags.h to solve the problem. Related GDB commit: 8cbde735e405 "gdbsupport: ignore -Wenum-constexpr-conversion in enum-flags.h" --- gdb-10.2.patch | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/gdb-10.2.patch b/gdb-10.2.patch index 3694b131..23ceca95 100644 --- a/gdb-10.2.patch +++ b/gdb-10.2.patch @@ -16118,3 +16118,46 @@ exit 0 subclass (SYMBOL_NONE) { /* We can't use an initializer list for members of a base class, and +--- gdb-10.2/gdbsupport/enum-flags.h.orig ++++ gdb-10.2/gdbsupport/enum-flags.h +@@ -81,9 +81,12 @@ + template + struct enum_underlying_type + { ++ DIAGNOSTIC_PUSH ++ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION + typedef typename + integer_for_size(T (-1) < T (0))>::type + type; ++ DIAGNOSTIC_POP + }; + + template + +--- gdb-10.2/include/diagnostics.h.orig ++++ gdb-10.2/include/diagnostics.h +@@ -61,6 +61,24 @@ + # 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 ++ ++# 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") ++ ++# if __has_warning ("-Wenum-constexpr-conversion") ++# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ ++ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") ++# endif ++ + #elif defined (__GNUC__) /* GCC */ + + # if __GNUC__ >= 7