aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-05-11 15:46:59 -0400
committerJason Merrill <jason@redhat.com>2020-05-11 16:18:11 -0400
commit0f50f6daa140186a048cbf33f54f4591eabf5f12 (patch)
tree8f6ef8ad0d40a14488583b05c26a12f7fe23a7ad /gcc/cp/decl2.c
parent42e9f80bf4f6a38733c221c03a512c432cdb784f (diff)
downloadgcc-0f50f6daa140186a048cbf33f54f4591eabf5f12.zip
gcc-0f50f6daa140186a048cbf33f54f4591eabf5f12.tar.gz
gcc-0f50f6daa140186a048cbf33f54f4591eabf5f12.tar.bz2
c++: tree walk into TYPENAME_TYPE.
While looking at 92583/92654 it occurred to me that typename types needed the same fix. So extract_locals_r also needs to see the TYPE_CONTEXT of a TYPENAME_TYPE. But it must not look through a typedef. Most tree walking in the front end wants to walk through the syntactic form of a type of expression, and doesn't care about the type referred to by a typedef. But min_vis_r does care. gcc/cp/ChangeLog 2020-05-11 Jason Merrill <jason@redhat.com> PR c++/92583 PR c++/92654 * tree.c (cp_walk_subtrees): Stop at typedefs. Handle TYPENAME_TYPE here. * pt.c (find_parameter_packs_r): Not here. (for_each_template_parm_r): Clear *walk_subtrees. * decl2.c (min_vis_r): Look through typedefs.
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 8d3ac31..4767d53 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2328,26 +2328,30 @@ static tree
min_vis_r (tree *tp, int *walk_subtrees, void *data)
{
int *vis_p = (int *)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)))
{
+ this_vis = VISIBILITY_ANON;
*walk_subtrees = 0;
}
- else if (OVERLOAD_TYPE_P (*tp)
- && !TREE_PUBLIC (TYPE_MAIN_DECL (*tp)))
+ else if (CLASS_TYPE_P (*tp))
{
- *vis_p = VISIBILITY_ANON;
- return *tp;
+ this_vis = CLASSTYPE_VISIBILITY (*tp);
+ *walk_subtrees = 0;
}
- else if (CLASS_TYPE_P (*tp)
- && CLASSTYPE_VISIBILITY (*tp) > *vis_p)
- *vis_p = CLASSTYPE_VISIBILITY (*tp);
else if (TREE_CODE (*tp) == ARRAY_TYPE
&& uses_template_parms (TYPE_DOMAIN (*tp)))
- {
- int evis = expr_visibility (TYPE_MAX_VALUE (TYPE_DOMAIN (*tp)));
- if (evis > *vis_p)
- *vis_p = evis;
- }
+ this_vis = expr_visibility (TYPE_MAX_VALUE (TYPE_DOMAIN (*tp)));
+
+ if (this_vis > *vis_p)
+ *vis_p = this_vis;
+
return NULL;
}