From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 6AC2038438A3 for ; Fri, 8 Jan 2021 19:29:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6AC2038438A3 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-EUDwxUUaM_q_EanO8d4bnA-1; Fri, 08 Jan 2021 14:29:17 -0500 X-MC-Unique: EUDwxUUaM_q_EanO8d4bnA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78A621927800 for ; Fri, 8 Jan 2021 19:29:15 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-11.ams2.redhat.com [10.36.112.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 119491971D; Fri, 8 Jan 2021 19:29:08 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 108JT6Gf063062 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 8 Jan 2021 20:29:06 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 108JT5FJ063061; Fri, 8 Jan 2021 20:29:05 +0100 Date: Fri, 8 Jan 2021 20:29:05 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++, abi: Fix abi_tag attribute handling [PR98481] Message-ID: <20210108192905.GY725145@tucnak> Reply-To: Jakub Jelinek References: <20210107164718.GP725145@tucnak> <07f1435c-44ce-4b00-5491-a9f07a547148@redhat.com> MIME-Version: 1.0 In-Reply-To: <07f1435c-44ce-4b00-5491-a9f07a547148@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2021 19:29:20 -0000 On Fri, Jan 08, 2021 at 02:22:59PM -0500, Jason Merrill wrote: > I like the idea to use *walk_subtrees to distinguish between walking > syntactic subtrees and walking type-identity subtrees. But it should be > more general; how does this look to you? LGTM, thanks. > diff --git a/gcc/cp/class.c b/gcc/cp/class.c > index c41ac7deefe..00c0dba0a55 100644 > --- a/gcc/cp/class.c > +++ b/gcc/cp/class.c > @@ -1507,6 +1507,10 @@ mark_or_check_tags (tree t, tree *tp, abi_tag_data *p, bool val) > static tree > find_abi_tags_r (tree *tp, int *walk_subtrees, void *data) > { > + if (TYPE_P (*tp) && *walk_subtrees == 1) > + /* Tell cp_walk_subtrees to look though typedefs. */ > + *walk_subtrees = 2; > + > if (!OVERLOAD_TYPE_P (*tp)) > return NULL_TREE; > > @@ -1527,6 +1531,10 @@ find_abi_tags_r (tree *tp, int *walk_subtrees, void *data) > static tree > mark_abi_tags_r (tree *tp, int *walk_subtrees, void *data) > { > + if (TYPE_P (*tp) && *walk_subtrees == 1) > + /* Tell cp_walk_subtrees to look though typedefs. */ > + *walk_subtrees = 2; > + > if (!OVERLOAD_TYPE_P (*tp)) > return NULL_TREE; > > diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c > index b10671091b5..b087753cfba 100644 > --- a/gcc/cp/decl2.c > +++ b/gcc/cp/decl2.c > @@ -2358,9 +2358,6 @@ min_vis_r (tree *tp, int *walk_subtrees, void *data) > int this_vis = VISIBILITY_DEFAULT; > if (! TYPE_P (*tp)) > *walk_subtrees = 0; > - else if (typedef_variant_p (*tp)) > - /* Look through typedefs despite cp_walk_subtrees. */ > - this_vis = type_visibility (DECL_ORIGINAL_TYPE (TYPE_NAME (*tp))); > else if (OVERLOAD_TYPE_P (*tp) > && !TREE_PUBLIC (TYPE_MAIN_DECL (*tp))) > { > @@ -2379,6 +2376,10 @@ min_vis_r (tree *tp, int *walk_subtrees, void *data) > if (this_vis > *vis_p) > *vis_p = this_vis; > > + /* Tell cp_walk_subtrees to look through typedefs. */ > + if (*walk_subtrees == 1) > + *walk_subtrees = 2; > + > return NULL; > } > > diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c > index 82027cc9abf..c536eb581a7 100644 > --- a/gcc/cp/tree.c > +++ b/gcc/cp/tree.c > @@ -5146,16 +5146,26 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func, > > if (TYPE_P (*tp)) > { > - /* Walk into template args without looking through typedefs. */ > - if (tree ti = TYPE_TEMPLATE_INFO_MAYBE_ALIAS (*tp)) > - WALK_SUBTREE (TI_ARGS (ti)); > - /* Don't look through typedefs; walk_tree_fns that want to look through > - typedefs (like min_vis_r) need to do that themselves. */ > - if (typedef_variant_p (*tp)) > + /* If *WALK_SUBTREES_P is 1, we're interested in the syntactic form of > + the argument, so don't look through typedefs, but do walk into > + template arguments for alias templates (and non-typedefed classes). > + > + If *WALK_SUBTREES_P > 1, we're interested in type identity or > + equivalence, so look through typedefs, ignoring template arguments for > + alias templates, and walk into template args of classes. > + > + See find_abi_tags_r for an example of setting *WALK_SUBTREES_P to 2 > + when that's the behavior the walk_tree_fn wants. */ > + if (*walk_subtrees_p == 1 && typedef_variant_p (*tp)) > { > + if (tree ti = TYPE_ALIAS_TEMPLATE_INFO (*tp)) > + WALK_SUBTREE (TI_ARGS (ti)); > *walk_subtrees_p = 0; > return NULL_TREE; > } > + > + if (tree ti = TYPE_TEMPLATE_INFO (*tp)) > + WALK_SUBTREE (TI_ARGS (ti)); > } > > /* Not one of the easy cases. We must explicitly go through the Jakub