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 3E76C3858407 for ; Wed, 22 Nov 2023 09:44:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E76C3858407 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3E76C3858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700646253; cv=none; b=rei3O/Jxv0wACWz6kRXNVSEV9YfxcMqushlLY9/rksFPwIfmYQIA/aYT4N7dR2gMa999i8S4cSd0vCg5wFEO1cc8i82eaQEK4vo6Nqklz+t13xxDpNKDcFEBzAuKmjZ3Q/xG658m7cee/qm7L+i81bhzrprEDYo3bg7D4rToJOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700646253; c=relaxed/simple; bh=U1lfH3a0H7G2uAJCKnPAvO3AHlILKJVEjpu6bUxoesw=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=aaZhk/yHecsdIfY5g+uic38Q6OvFh5PndyfuntGfggC58Cpj/pnco1saOlWcpxgFjcJ5vPZ7gA2d21gZHltttct7pBYDMur7wHSF36DtnR3270ZT5rlwH1bJ65HZa0cR//Gjy+XHIZHKutikeF0fYTSzJ21E4efJn7FqHk0eyLg= ARC-Authentication-Results: i=1; server2.sourceware.org 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 0E18D21907; Wed, 22 Nov 2023 09:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700646250; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eF5sAQqMoyHhTVcNjbEKWV8J7/E8cyA3Ti0LUmdzj5c=; b=k0gotpbQeLcnMzPUclkrQwXDLeUmmhDzLS/wvBsIv3NMGYAq+kuK7ysZcW9ThkKuHZZJ5v wkbzzrkkMB4248JOero0swB103j6La8OS/B+yy3cLZPD4nGsmUz0KPDng3YkDNB6oXtTxu jhy8amrW+7Bwl+UoA9Z1qHONYBmUhx8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700646250; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eF5sAQqMoyHhTVcNjbEKWV8J7/E8cyA3Ti0LUmdzj5c=; b=tKSEe/KPlA5+1txXb8q6rK0FrasVx1bAn8oqbZyAISxizlnTO1lXsGql/dhkqj+7rGFRIZ O7ks3FYjsMOzRKCA== 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 AD48113461; Wed, 22 Nov 2023 09:44:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UwxOJmnNXWWAfwAAMHmgww (envelope-from ); Wed, 22 Nov 2023 09:44:09 +0000 Message-ID: <5a050134-3ab7-4d6f-b45f-45796e1cc37c@suse.de> Date: Wed, 22 Nov 2023 10:46:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 8/9] Use enum accessibility in types and member functions Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org Cc: Simon Marchi , Keith Seitz References: <20231103-field-bits-v3-0-273c40bcaf3d@adacore.com> <20231103-field-bits-v3-8-273c40bcaf3d@adacore.com> From: Tom de Vries In-Reply-To: <20231103-field-bits-v3-8-273c40bcaf3d@adacore.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -1.09 X-Spamd-Result: default: False [-1.09 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(3.00)[1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; BAYES_HAM(-3.00)[100.00%]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] 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,T_SCC_BODY_TEXT_LINE 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: On 11/3/23 17:09, Tom Tromey wrote: > This changes nested types and member functions to use the new > 'accessibility' enum, rather than separate private/protected flags. > This is done for consistency, but it also lets us simplify some other > code in the next patch. > FWIW, this breaks the build for me with system gcc 7.5.0: ... /data/vries/gdb/src/gdb/gdbtypes.h:721:51: error: ‘field::m_accessibility’ is too small to hold all values of ‘enum class accessibility’ [-Werror] ENUM_BITFIELD (accessibility) m_accessibility : 2; ^ /data/vries/gdb/src/gdb/gdbtypes.h:1615:49: error: ‘fn_field::accessibility’ is too small to hold all values of ‘enum class accessibility’ [-Werror] ENUM_BITFIELD (accessibility) accessibility : 2; ^ /data/vries/gdb/src/gdb/gdbtypes.h:1661:49: error: ‘decl_field::accessibility’ is too small to hold all values of ‘enum class accessibility’ [-Werror] ENUM_BITFIELD (accessibility) accessibility : 2; ^ ... I can fix this by using --disable-werror. Also builds fine when I switch to gcc 9.3.1 with --enable-werror. Thanks, - Tom > Acked-By: Simon Marchi > Reviewed-by: Keith Seitz > --- > gdb/dwarf2/read.c | 8 ++++---- > gdb/gdbtypes.h | 27 ++++++++++++++------------- > gdb/stabsread.c | 4 ++-- > 3 files changed, 20 insertions(+), 19 deletions(-) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index e52ca5b5b83..0d8c24ad5b1 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -11714,10 +11714,10 @@ dwarf2_add_type_defn (struct field_info *fip, struct die_info *die, > /* The assumed value if neither private nor protected. */ > break; > case DW_ACCESS_private: > - fp.is_private = 1; > + fp.accessibility = accessibility::PRIVATE; > break; > case DW_ACCESS_protected: > - fp.is_protected = 1; > + fp.accessibility = accessibility::PROTECTED; > break; > } > > @@ -12076,10 +12076,10 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, > switch (accessibility) > { > case DW_ACCESS_private: > - fnp->is_private = 1; > + fnp->accessibility = accessibility::PRIVATE; > break; > case DW_ACCESS_protected: > - fnp->is_protected = 1; > + fnp->accessibility = accessibility::PROTECTED; > break; > } > > diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h > index bec69bdc3d1..d3c7a206b34 100644 > --- a/gdb/gdbtypes.h > +++ b/gdb/gdbtypes.h > @@ -1611,8 +1611,8 @@ struct fn_field > > unsigned int is_const:1; > unsigned int is_volatile:1; > - unsigned int is_private:1; > - unsigned int is_protected:1; > + /* Accessibility of the field. */ > + ENUM_BITFIELD (accessibility) accessibility : 2; > unsigned int is_artificial:1; > > /* * A stub method only has some fields valid (but they are enough > @@ -1657,11 +1657,8 @@ struct decl_field > > struct type *type; > > - /* * True if this field was declared protected, false otherwise. */ > - unsigned int is_protected : 1; > - > - /* * True if this field was declared private, false otherwise. */ > - unsigned int is_private : 1; > + /* Accessibility of the field. */ > + ENUM_BITFIELD (accessibility) accessibility : 2; > }; > > /* * C++ language-specific information for TYPE_CODE_STRUCT and > @@ -1984,8 +1981,10 @@ extern void set_type_vptr_basetype (struct type *, struct type *); > #define TYPE_FN_FIELD_ARGS(thisfn, n) (((thisfn)[n].type)->fields ()) > #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const) > #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile) > -#define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private) > -#define TYPE_FN_FIELD_PROTECTED(thisfn, n) ((thisfn)[n].is_protected) > +#define TYPE_FN_FIELD_PRIVATE(thisfn, n) \ > + ((thisfn)[n].accessibility == accessibility::PRIVATE) > +#define TYPE_FN_FIELD_PROTECTED(thisfn, n) \ > + ((thisfn)[n].accessibility == accessibility::PROTECTED) > #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial) > #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub) > #define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor) > @@ -2008,9 +2007,9 @@ extern void set_type_vptr_basetype (struct type *, struct type *); > #define TYPE_TYPEDEF_FIELD_COUNT(thistype) \ > TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count > #define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \ > - TYPE_TYPEDEF_FIELD (thistype, n).is_protected > + (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PROTECTED) > #define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \ > - TYPE_TYPEDEF_FIELD (thistype, n).is_private > + (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PRIVATE) > > #define TYPE_NESTED_TYPES_ARRAY(thistype) \ > TYPE_CPLUS_SPECIFIC (thistype)->nested_types > @@ -2023,9 +2022,11 @@ extern void set_type_vptr_basetype (struct type *, struct type *); > #define TYPE_NESTED_TYPES_COUNT(thistype) \ > TYPE_CPLUS_SPECIFIC (thistype)->nested_types_count > #define TYPE_NESTED_TYPES_FIELD_PROTECTED(thistype, n) \ > - TYPE_NESTED_TYPES_FIELD (thistype, n).is_protected > + (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \ > + == accessibility::PROTECTED) > #define TYPE_NESTED_TYPES_FIELD_PRIVATE(thistype, n) \ > - TYPE_NESTED_TYPES_FIELD (thistype, n).is_private > + (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \ > + == accessibility::PRIVATE) > > #define TYPE_IS_OPAQUE(thistype) \ > ((((thistype)->code () == TYPE_CODE_STRUCT) \ > diff --git a/gdb/stabsread.c b/gdb/stabsread.c > index 334371c2e46..fbf11701337 100644 > --- a/gdb/stabsread.c > +++ b/gdb/stabsread.c > @@ -2372,10 +2372,10 @@ read_member_functions (struct stab_field_info *fip, const char **pp, > switch (*(*pp)++) > { > case VISIBILITY_PRIVATE: > - new_sublist->fn_field.is_private = 1; > + new_sublist->fn_field.accessibility = accessibility::PRIVATE; > break; > case VISIBILITY_PROTECTED: > - new_sublist->fn_field.is_protected = 1; > + new_sublist->fn_field.accessibility = accessibility::PROTECTED; > break; > } > >