aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/name-lookup.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r--gcc/cp/name-lookup.c106
1 files changed, 23 insertions, 83 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 5dcaab4..e951fb7 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -6719,8 +6719,6 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
typedef struct C {} C;
correctly. */
- tree found = NULL_TREE;
- bool reveal = false;
if (tree type = iter->type)
{
if (qualify_lookup (type, LOOK_want::TYPE)
@@ -6728,9 +6726,11 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
|| LOCAL_BINDING_P (iter)
|| DECL_CONTEXT (type) == iter->scope->this_entity))
{
- found = type;
if (how != TAG_how::HIDDEN_FRIEND)
- reveal = HIDDEN_TYPE_BINDING_P (iter);
+ /* It is no longer a hidden binding. */
+ HIDDEN_TYPE_BINDING_P (iter) = false;
+
+ return type;
}
}
else
@@ -6739,32 +6739,12 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
&& (how != TAG_how::CURRENT_ONLY
|| !INHERITED_VALUE_BINDING_P (iter)))
{
- found = iter->value;
- if (how != TAG_how::HIDDEN_FRIEND)
- reveal = !iter->type && HIDDEN_TYPE_BINDING_P (iter);
- }
- }
-
- if (found)
- {
- if (reveal)
- {
- /* It is no longer a hidden binding. */
- HIDDEN_TYPE_BINDING_P (iter) = false;
-
- /* Unanticipate the decl itself. */
- DECL_FRIEND_P (found) = false;
+ if (how != TAG_how::HIDDEN_FRIEND && !iter->type)
+ /* It is no longer a hidden binding. */
+ HIDDEN_TYPE_BINDING_P (iter) = false;
- gcc_checking_assert (TREE_CODE (found) != TEMPLATE_DECL);
-
- if (tree ti = TYPE_TEMPLATE_INFO (TREE_TYPE (found)))
- {
- tree tmpl = TI_TEMPLATE (ti);
- DECL_FRIEND_P (tmpl) = false;
- }
+ return iter->value;
}
-
- return found;
}
}
@@ -6781,61 +6761,31 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
if (tree *slot = find_namespace_slot (ns, name))
{
/* If this is the kind of thing we're looking for, we're done. */
- tree found = NULL_TREE;
- bool reveal = false;
-
if (tree type = MAYBE_STAT_TYPE (*slot))
{
- found = type;
if (how != TAG_how::HIDDEN_FRIEND)
- {
- reveal = STAT_TYPE_HIDDEN_P (*slot);
- STAT_TYPE_HIDDEN_P (*slot) = false;
- }
+ /* No longer hidden. */
+ STAT_TYPE_HIDDEN_P (*slot) = false;
+
+ return type;
}
else if (tree decl = MAYBE_STAT_DECL (*slot))
{
if (qualify_lookup (decl, LOOK_want::TYPE))
{
- found = decl;
-
- if (how != TAG_how::HIDDEN_FRIEND && STAT_HACK_P (*slot))
+ if (how != TAG_how::HIDDEN_FRIEND && STAT_HACK_P (*slot)
+ && STAT_DECL_HIDDEN_P (*slot))
{
- reveal = STAT_DECL_HIDDEN_P (*slot);
- if (reveal)
- {
- if (STAT_TYPE (*slot))
- STAT_DECL_HIDDEN_P (*slot) = false;
- else
- /* There is no type, just remove the stat
- hack. */
- *slot = decl;
- }
+ if (STAT_TYPE (*slot))
+ STAT_DECL_HIDDEN_P (*slot) = false;
+ else
+ /* There is no type, just remove the stat
+ hack. */
+ *slot = decl;
}
- }
- }
- if (found)
- {
- if (reveal)
- {
- /* Reveal the previously hidden thing. */
- DECL_FRIEND_P (found) = false;
-
- if (TREE_CODE (found) == TEMPLATE_DECL)
- {
- tree res = DECL_TEMPLATE_RESULT (found);
- if (DECL_LANG_SPECIFIC (res))
- DECL_FRIEND_P (res) = false;
- }
- else if (tree ti = TYPE_TEMPLATE_INFO (TREE_TYPE (found)))
- {
- tree tmpl = TI_TEMPLATE (ti);
- DECL_FRIEND_P (tmpl) = false;
- }
+ return decl;
}
-
- return found;
}
}
@@ -7017,18 +6967,8 @@ do_pushtag (tree name, tree type, TAG_how how)
tdef = create_implicit_typedef (name, type);
DECL_CONTEXT (tdef) = FROB_CONTEXT (context);
- bool is_friend = how == TAG_how::HIDDEN_FRIEND;
- if (is_friend)
- {
- // FIXME: can go away
- /* This is a friend. Make this TYPE_DECL node hidden from
- ordinary name lookup. Its corresponding TEMPLATE_DECL
- will be marked in push_template_decl. */
- retrofit_lang_decl (tdef);
- DECL_FRIEND_P (tdef) = 1;
- }
-
- decl = maybe_process_template_type_declaration (type, is_friend, b);
+ decl = maybe_process_template_type_declaration
+ (type, how == TAG_how::HIDDEN_FRIEND, b);
if (decl == error_mark_node)
return decl;