From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 04A05385B522 for ; Tue, 15 Aug 2023 18:13:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04A05385B522 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CC8052190B for ; Tue, 15 Aug 2023 18:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692123216; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d2esfnY6wuwxACNVpOuVLU+1EFnhQ/9/QPLYFkrUiVk=; b=2VLQx20J4512dsX5A8ayScmeZVEshpRspAutgYLQDXFgK3wYlC/+GRO7p/mAkQIN6bXbaE lgfJRTdqiYZqaolI2FEvB94aqxj0gD/aTUhAnAr37TuiwW0tgiw8Iz61kOHk09h2x8G0W8 /7zC+pdWb8l12ts8U4QBZpTcL5LTrHM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692123216; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d2esfnY6wuwxACNVpOuVLU+1EFnhQ/9/QPLYFkrUiVk=; b=rsPCl107WOTx/82DIXgq9MoW/2QCy7Ds2vp960iNuyT4kxFrufwJbUBn3snmwChpOE+nvx H/usSw59XrykfdCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B7C7F1390C for ; Tue, 15 Aug 2023 18:13:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oGTPK1DA22RuQAAAMHmgww (envelope-from ) for ; Tue, 15 Aug 2023 18:13:36 +0000 From: Tom de Vries 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 Message-Id: <20230815181309.8595-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230815181309.8595-1-tdevries@suse.de> References: <20230815181309.8595-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 #include +#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 { 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 {} (*exc.message); return result; -- 2.35.3