mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
[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.
This commit is contained in:
parent
f0ae7030f0
commit
24a601dd70
12
gdb/remote.c
12
gdb/remote.c
@ -10850,7 +10850,8 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
|
||||
char *p;
|
||||
enum Z_packet_type packet = watchpoint_to_Z_packet (type);
|
||||
|
||||
if (m_features.packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
|
||||
if (m_features.packet_support ((to_underlying (PACKET_Z0)
|
||||
+ to_underlying (packet))) == PACKET_DISABLE)
|
||||
return 1;
|
||||
|
||||
/* Make sure the remote is pointing at the right process, if
|
||||
@ -10867,7 +10868,8 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
|
||||
putpkt (rs->buf);
|
||||
getpkt (&rs->buf, 0);
|
||||
|
||||
switch (m_features.packet_ok (rs->buf, PACKET_Z0 + packet))
|
||||
switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
|
||||
+ to_underlying (packet))))
|
||||
{
|
||||
case PACKET_ERROR:
|
||||
return -1;
|
||||
@ -10898,7 +10900,8 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
|
||||
char *p;
|
||||
enum Z_packet_type packet = watchpoint_to_Z_packet (type);
|
||||
|
||||
if (m_features.packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
|
||||
if (m_features.packet_support ((to_underlying (PACKET_Z0)
|
||||
+ to_underlying (packet))) == PACKET_DISABLE)
|
||||
return -1;
|
||||
|
||||
/* Make sure the remote is pointing at the right process, if
|
||||
@ -10914,7 +10917,8 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
|
||||
putpkt (rs->buf);
|
||||
getpkt (&rs->buf, 0);
|
||||
|
||||
switch (m_features.packet_ok (rs->buf, PACKET_Z0 + packet))
|
||||
switch (m_features.packet_ok (rs->buf, (to_underlying (PACKET_Z0)
|
||||
+ to_underlying (packet))))
|
||||
{
|
||||
case PACKET_ERROR:
|
||||
case PACKET_UNKNOWN:
|
||||
|
@ -2495,7 +2495,8 @@ rs6000_register_name (struct gdbarch *gdbarch, int regno)
|
||||
|
||||
/* Hide the upper halves of the cvs0~cvs31 registers. */
|
||||
if (PPC_CVSR0_UPPER_REGNUM <= regno
|
||||
&& regno < PPC_CVSR0_UPPER_REGNUM + ppc_num_gprs)
|
||||
&& regno < (to_underlying (PPC_CVSR0_UPPER_REGNUM)
|
||||
+ to_underlying (ppc_num_gprs)))
|
||||
return "";
|
||||
|
||||
/* Check if the SPE pseudo registers are available. */
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user