From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/7] [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion
Date: Tue, 15 Aug 2023 20:13:03 +0200 [thread overview]
Message-ID: <20230815181309.8595-2-tdevries@suse.de> (raw)
In-Reply-To: <20230815181309.8595-1-tdevries@suse.de>
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.
---
gdb/remote.c | 12 ++++++++----
gdb/rs6000-tdep.c | 3 ++-
gdbsupport/common-exceptions.h | 4 +++-
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 6fefabac0ce..e01da795ec8 100644
--- a/gdb/remote.c
+++ b/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:
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index ff83743da36..71390513ad2 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -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. */
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index f9b59ece736..e4750211448 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;
--
2.35.3
next prev parent reply other threads:[~2023-08-15 18:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
2023-08-15 18:13 ` Tom de Vries [this message]
2023-08-15 18:13 ` [PATCH 2/7] [gdb/build, c++20] Stop using deprecated is_pod Tom de Vries
2023-08-15 18:13 ` [PATCH 3/7] [gdb/build, c++20] Fix DISABLE_COPY_AND_ASSIGN use in ui_out_emit_type Tom de Vries
2023-08-15 18:13 ` [PATCH 4/7] [gdb/build, c++20] Fix deprecated implicit capture of this Tom de Vries
2023-08-15 18:13 ` [PATCH 5/7] [gdb/build, c++20] Fix invalid conversion in test_symbols Tom de Vries
2023-08-15 18:13 ` [PATCH 6/7] [gdb/build] Return reference in target_read_auxv Tom de Vries
2023-08-16 18:23 ` Tom Tromey
2023-08-15 18:13 ` [PATCH 7/7] [gdb/build, c++20] Handle deprecated std::allocator::construct Tom de Vries
2023-08-16 18:27 ` [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom Tromey
2023-08-21 11:04 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230815181309.8595-2-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).