From 3dd0d3ee1d2a988e7f3a3e8f009fcf328f16d2ed Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 7 Jan 2021 17:47:18 +0100 Subject: c++, abi: Fix abi_tag attribute handling [PR98481] In GCC10 cp_walk_subtrees has been changed to walk template arguments. As the following testcase, that changed the mangling of some functions. I believe the previous behavior that find_abi_tags_r doesn't recurse into template args has been the correct one, but setting *walk_subtrees = 0 for the types and handling the types subtree walking manually in find_abi_tags_r looks too hard, there are a lot of subtrees and details what should and shouldn't be walked, both in tree.c (walk_type_fields there, which is static) and in cp_walk_subtrees itself. The following patch abuses the fact that *walk_subtrees is an int to tell cp_walk_subtrees it shouldn't walk the template args. Co-authored-by: Jason Merrill gcc/cp/ChangeLog: PR c++/98481 * class.c (find_abi_tags_r): Set *walk_subtrees to 2 instead of 1 for types. (mark_abi_tags_r): Likewise. * decl2.c (min_vis_r): Likewise. * tree.c (cp_walk_subtrees): If *walk_subtrees_p is 2, look through typedefs. gcc/testsuite/ChangeLog: PR c++/98481 * g++.dg/abi/abi-tag24.C: New test. --- gcc/cp/decl2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/cp/decl2.c') diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index b106710..b087753 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; } -- cgit v1.1