diff options
author | Tom de Vries <tdevries@suse.de> | 2023-08-17 10:41:34 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-08-17 10:41:34 +0200 |
commit | 24a601dd70a53fc87f33196774f8d883be31d2fe (patch) | |
tree | 9f6f6dff80927de482ec90df07240ea45867cc47 /gdbsupport | |
parent | f0ae7030f00ea08c9ec09493b6ece447879bcab4 (diff) | |
download | gdb-24a601dd70a53fc87f33196774f8d883be31d2fe.zip gdb-24a601dd70a53fc87f33196774f8d883be31d2fe.tar.gz gdb-24a601dd70a53fc87f33196774f8d883be31d2fe.tar.bz2 |
[gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion
When building gdb with clang 15 and -std=c++20, I run into:
...
gdbsupport/common-exceptions.h:203:32: error: arithmetic between different \
enumeration types ('const enum return_reason' and 'const enum errors') is \
deprecated [-Werror,-Wdeprecated-enum-enum-conversion]
size_t result = exc.reason + exc.error;
~~~~~~~~~~ ^ ~~~~~~~~~
...
Fix this by using to_underlying.
Likewise in a few other places.
Tested on x86_64-linux.
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/common-exceptions.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h index f9b59ec..e475021 100644 --- a/gdbsupport/common-exceptions.h +++ b/gdbsupport/common-exceptions.h @@ -26,6 +26,8 @@ #include <string> #include <functional> +#include "gdbsupport/underlying.h" + /* Reasons for calling throw_exceptions(). NOTE: all reason values must be different from zero. enum value 0 is reserved for internal use as the return value from an initial setjmp(). */ @@ -200,7 +202,7 @@ struct hash<gdb_exception> { size_t operator() (const gdb_exception &exc) const { - size_t result = exc.reason + exc.error; + size_t result = to_underlying (exc.reason) + to_underlying (exc.error); if (exc.message != nullptr) result += std::hash<std::string> {} (*exc.message); return result; |