From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by sourceware.org (Postfix) with ESMTPS id BEF743857818 for ; Mon, 14 Sep 2020 13:53:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BEF743857818 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wr1-f43.google.com with SMTP id t10so18876482wrv.1 for ; Mon, 14 Sep 2020 06:53:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KB+tHASzKqPJFv8Gxfnsy9CiDPLKHiNQ2OFizDljIsE=; b=bp4ZFVlZLvnT1r7laSD5NEoY3JAJDnp6ci5ZXCDmRf/Lydy8Ux2W/X8T4T1PYxkTA6 IITNH0mCvC9j5b08AUDX0UO+KChofbl6gFNnI2WiFqb83VBx7KcvDjDVioj1PUrIuJZu x+jSIp+IgsQWCgp87yHaa7062peo/3xtn6y0boTKIHcUUmZGhkMa+W+G2+4tRFBSUF7Y tmrVButlSbaTo4YgfndeUi+PsjTk9BxQLWGDq8M4JmJrpzfDMlL7C2eyGYdfMHDFj7lC wQwc2xL3Hx2hnlF0A6VotHHUtIBeQdVzkBrmLB9XQJW6g349EDrPw8UBJAIdobY7JvMw AwZg== X-Gm-Message-State: AOAM530dw+lgGe8wgpl1xM+gW0rAFdlSHOt9nLoANhFyJMqtpsSRhMOD mtspDL5DQbjZ9vgPkcHEPQTQbWyrW6DQTg== X-Google-Smtp-Source: ABdhPJwtBqbnbAPcFNPctwLP37gNyW9EytDjRq3vDpdw4iaz6PxcqbbkBwu4XKgzlg9REjs3ZhOuHg== X-Received: by 2002:adf:f290:: with SMTP id k16mr17162419wro.124.1600091589775; Mon, 14 Sep 2020 06:53:09 -0700 (PDT) Received: from ?IPv6:2001:8a0:f905:5600:eefd:c63:53e0:3e8a? ([2001:8a0:f905:5600:eefd:c63:53e0:3e8a]) by smtp.gmail.com with ESMTPSA id r14sm20804040wrn.56.2020.09.14.06.53.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 06:53:08 -0700 (PDT) Subject: Re: [PATCH 2/3] Use type_instance_flags more throughout To: Andrew Burgess References: <20200821144523.19451-1-pedro@palves.net> <20200821144523.19451-3-pedro@palves.net> <20200826152109.GV853475@embecosm.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <4c27500f-18b8-015e-0d89-9f18d652c872@palves.net> Date: Mon, 14 Sep 2020 14:53:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20200826152109.GV853475@embecosm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2020 13:53:13 -0000 On 8/26/20 4:21 PM, Andrew Burgess wrote: >> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h >> index 55a6dafb7e..b42cef6137 100644 >> --- a/gdb/gdbtypes.h >> +++ b/gdb/gdbtypes.h >> @@ -1585,7 +1585,10 @@ extern void allocate_gnat_aux_type (struct type *); >> TYPE_ZALLOC (type, \ >> sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff))) >> >> -#define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags >> +#define TYPE_INSTANCE_FLAGS(thistype) \ >> + type_instance_flags ((enum type_instance_flag_value) (thistype)->instance_flags) >> +#define SET_TYPE_INSTANCE_FLAGS(thistype, flags) \ >> + (thistype)->instance_flags = flags > > There are some places where you've not updated a use of > TYPE_INSTANCE_FLAGS. The patch below fixes these. In order to find > these I changed TYPE_INSTANCE_FLAGS to make use of a member function > returning a 'const type_instance_flags'. > > Feel free to take any parts of this patch you think are useful. Wow, these shouldn't even compile. That is showing a hole in enum_flags. > > - TYPE_INSTANCE_FLAGS (builtin_d_type->builtin_byte) > - |= TYPE_INSTANCE_FLAG_NOTTEXT; TYPE_INSTANCE_FLAGS does a cast, so this is the equivalent of: int flags = 0; (int) flags |= 1; which of course doesn't compile: test.c:1:18: error: lvalue required as left operand of assignment 1 | (int) flags |= 1; | ^ I'm merging the patch below into the main enum flags patch, to disable the rvalue versions of compound assignment. It catches the spots you caught as well: src/gdb/d-lang.c: In function ‘void* build_d_types(gdbarch*)’: src/gdb/d-lang.c:325:8: error: use of deleted function ‘void enum_flags::operator|=(enum_flags) && [with E = type_instance_flag_value]’ 325 | |= TYPE_INSTANCE_FLAG_NOTTEXT; | ^~~~~~~~~~~~~~~~~~~~~~~~~~ src/gdb/ft32-tdep.c: In function ‘gdbarch* ft32_gdbarch_init(gdbarch_info, gdbarch_list*)’: src/gdb/ft32-tdep.c:580:42: error: use of deleted function ‘void enum_flags::operator|=(enum_flags) && [with E = type_instance_flag_value]’ 580 | TYPE_INSTANCE_FLAGS (tdep->pc_type) |= TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I'll merge your changes into the type_instance_flags patch. >From aadb29540a43d96dc234d0d8126e5081926eec02 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 14 Sep 2020 14:48:34 +0100 Subject: [PATCH] delete rval --- gdb/unittests/enum-flags-selftests.c | 18 +++++++++--------- gdbsupport/enum-flags.h | 18 +++++++++++------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c index 17ab5c9b09..af585f04ae 100644 --- a/gdb/unittests/enum-flags-selftests.c +++ b/gdb/unittests/enum-flags-selftests.c @@ -174,9 +174,9 @@ CHECK_VALID (true, EF, EF () ^ RE ()) CHECK_VALID (false, void, RE () |= RE2 ()) CHECK_VALID (false, void, RE () &= RE2 ()) CHECK_VALID (false, void, RE () ^= RE2 ()) -CHECK_VALID (true, RE&, RE () |= RE ()) -CHECK_VALID (true, RE&, RE () &= RE ()) -CHECK_VALID (true, RE&, RE () ^= RE ()) +CHECK_VALID (false, void, RE () |= RE ()) +CHECK_VALID (false, void, RE () &= RE ()) +CHECK_VALID (false, void, RE () ^= RE ()) /* operator OP= (raw_enum, raw_enum), lvalue ref on the lhs. */ @@ -192,9 +192,9 @@ CHECK_VALID (true, RE&, re ^= RE ()) CHECK_VALID (false, void, EF () |= RE2 ()) CHECK_VALID (false, void, EF () &= RE2 ()) CHECK_VALID (false, void, EF () ^= RE2 ()) -CHECK_VALID (true, EF&, EF () |= RE ()) -CHECK_VALID (true, EF&, EF () &= RE ()) -CHECK_VALID (true, EF&, EF () ^= RE ()) +CHECK_VALID (false, void, EF () |= RE ()) +CHECK_VALID (false, void, EF () &= RE ()) +CHECK_VALID (false, void, EF () ^= RE ()) /* operator OP= (enum_flags, raw_enum), lvalue ref on the lhs. */ @@ -210,9 +210,9 @@ CHECK_VALID (true, EF&, ef ^= EF ()) CHECK_VALID (false, void, EF () |= EF2 ()) CHECK_VALID (false, void, EF () &= EF2 ()) CHECK_VALID (false, void, EF () ^= EF2 ()) -CHECK_VALID (true, EF&, EF () |= EF ()) -CHECK_VALID (true, EF&, EF () &= EF ()) -CHECK_VALID (true, EF&, EF () ^= EF ()) +CHECK_VALID (false, void, EF () |= EF ()) +CHECK_VALID (false, void, EF () &= EF ()) +CHECK_VALID (false, void, EF () ^= EF ()) /* operator OP= (enum_flags, enum_flags), lvalue ref on the lhs. */ diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h index b3e317ecb9..d30d90b68d 100644 --- a/gdbsupport/enum-flags.h +++ b/gdbsupport/enum-flags.h @@ -147,22 +147,27 @@ class enum_flags : m_enum_value ((enum_type) 0) {} - enum_flags &operator&= (enum_flags e) + enum_flags &operator&= (enum_flags e) & { m_enum_value = (enum_type) (m_enum_value & e.m_enum_value); return *this; } - enum_flags &operator|= (enum_flags e) + enum_flags &operator|= (enum_flags e) & { m_enum_value = (enum_type) (m_enum_value | e.m_enum_value); return *this; } - enum_flags &operator^= (enum_flags e) + enum_flags &operator^= (enum_flags e) & { m_enum_value = (enum_type) (m_enum_value ^ e.m_enum_value); return *this; } + /* Delete rval versions. */ + void operator&= (enum_flags e) && = delete; + void operator|= (enum_flags e) && = delete; + void operator^= (enum_flags e) && = delete; + /* Like raw enums, allow conversion to the underlying type. */ constexpr operator underlying_type () const { @@ -278,9 +283,8 @@ using is_enum_flags_enum_type_t /* rval reference version. */ \ template > \ - constexpr enum_type & \ - OPERATOR_OP (enum_type &&e1, enum_type e2) \ - { return e1 = e1 OP e2; } \ + void \ + OPERATOR_OP (enum_type &&e1, enum_type e2) = delete; \ \ /* Delete compound assignment from unrelated types. */ \ \ @@ -291,7 +295,7 @@ using is_enum_flags_enum_type_t \ template > \ - constexpr enum_type & \ + void \ OPERATOR_OP (enum_type &&e1, other_enum_type e2) = delete; ENUM_FLAGS_GEN_BINOP (operator|, |) -- 2.14.5