Commit c0edbb32 by Nathan Sidwell Committed by Nathan Sidwell

cp-tree.h (ovl_skip_hidden): Declare.

	* cp-tree.h (ovl_skip_hidden): Declare.
	* tree.c (ovl_skip_hidden): New.
	* name-lookup.c (arg_assoc_namespace): Call ovl_skip_hidden.
	(lookup_arg_dependent_1): Likewise.
	(ambiguous_decl): Use DECL_HIDDEN_P, ovl_skip_hidden.
	(hidden_name_p, remove_hidden_names): Delete.
	(lookup_name_real_1): Do not strip hidden names.
	* name-lookup.h (hidden_name_p, remove_hidden_names): Delete.

From-SVN: r248423
parent 657e5f83
2017-05-24 Nathan Sidwell <nathan@acm.org> 2017-05-24 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (ovl_skip_hidden): Declare.
* tree.c (ovl_skip_hidden): New.
* name-lookup.c (arg_assoc_namespace): Call ovl_skip_hidden.
(lookup_arg_dependent_1): Likewise.
(ambiguous_decl): Use DECL_HIDDEN_P, ovl_skip_hidden.
(hidden_name_p, remove_hidden_names): Delete.
(lookup_name_real_1): Do not strip hidden names.
* name-lookup.h (hidden_name_p, remove_hidden_names): Delete.
* cp-tree.h (OVL_HIDDEN_P): New. * cp-tree.h (OVL_HIDDEN_P): New.
(ovl_iterator::hidden_p, ovl_iterator::reveal_node): New. (ovl_iterator::hidden_p, ovl_iterator::reveal_node): New.
(ovl_iterator::reveal_node): Declare. (ovl_iterator::reveal_node): Declare.
......
...@@ -6852,6 +6852,7 @@ extern tree ovl_make (tree fn, ...@@ -6852,6 +6852,7 @@ extern tree ovl_make (tree fn,
tree next = NULL_TREE); tree next = NULL_TREE);
extern tree ovl_insert (tree fn, tree maybe_ovl, extern tree ovl_insert (tree fn, tree maybe_ovl,
bool using_p = false); bool using_p = false);
extern tree ovl_skip_hidden (tree);
extern tree lookup_add (tree fns, tree lookup); extern tree lookup_add (tree fns, tree lookup);
extern void lookup_keep (tree lookup, bool keep); extern void lookup_keep (tree lookup, bool keep);
extern int is_overloaded_fn (tree); extern int is_overloaded_fn (tree);
......
...@@ -275,14 +275,10 @@ arg_assoc_namespace (struct arg_lookup *k, tree scope) ...@@ -275,14 +275,10 @@ arg_assoc_namespace (struct arg_lookup *k, tree scope)
if (!value) if (!value)
return false; return false;
value = ovl_skip_hidden (value);
for (; value; value = OVL_NEXT (value)) for (; value; value = OVL_NEXT (value))
{ {
/* We don't want to find arbitrary hidden functions via argument
dependent lookup. We only want to find friends of associated
classes, which we'll do via arg_assoc_class. */
if (hidden_name_p (OVL_CURRENT (value)))
continue;
if (add_function (k, OVL_CURRENT (value))) if (add_function (k, OVL_CURRENT (value)))
return true; return true;
} }
...@@ -630,7 +626,7 @@ lookup_arg_dependent_1 (tree name, tree fns, vec<tree, va_gc> *args) ...@@ -630,7 +626,7 @@ lookup_arg_dependent_1 (tree name, tree fns, vec<tree, va_gc> *args)
/* Remove any hidden friend functions from the list of functions /* Remove any hidden friend functions from the list of functions
found so far. They will be added back by arg_assoc_class as found so far. They will be added back by arg_assoc_class as
appropriate. */ appropriate. */
fns = remove_hidden_names (fns); fns = ovl_skip_hidden (fns);
k.name = name; k.name = name;
k.args = args; k.args = args;
...@@ -4347,7 +4343,7 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags) ...@@ -4347,7 +4343,7 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags)
/* Copy the type. */ /* Copy the type. */
type = new_binding->type; type = new_binding->type;
if (LOOKUP_NAMESPACES_ONLY (flags) if (LOOKUP_NAMESPACES_ONLY (flags)
|| (type && hidden_name_p (type) && !(flags & LOOKUP_HIDDEN))) || (type && !(flags & LOOKUP_HIDDEN) && DECL_HIDDEN_P (type)))
type = NULL_TREE; type = NULL_TREE;
/* Copy the value. */ /* Copy the value. */
...@@ -4355,7 +4351,7 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags) ...@@ -4355,7 +4351,7 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags)
if (val) if (val)
{ {
if (!(flags & LOOKUP_HIDDEN)) if (!(flags & LOOKUP_HIDDEN))
val = remove_hidden_names (val); val = ovl_skip_hidden (val);
if (val) if (val)
switch (TREE_CODE (val)) switch (TREE_CODE (val))
{ {
...@@ -4465,59 +4461,6 @@ qualify_lookup (tree val, int flags) ...@@ -4465,59 +4461,6 @@ qualify_lookup (tree val, int flags)
return true; return true;
} }
/* Given a lookup that returned VAL, decide if we want to ignore it or
not based on DECL_ANTICIPATED. */
bool
hidden_name_p (tree val)
{
if (DECL_P (val)
&& DECL_LANG_SPECIFIC (val)
&& TYPE_FUNCTION_OR_TEMPLATE_DECL_P (val)
&& DECL_ANTICIPATED (val))
return true;
if (TREE_CODE (val) == OVERLOAD)
{
for (tree o = val; o; o = OVL_CHAIN (o))
if (!hidden_name_p (OVL_FUNCTION (o)))
return false;
return true;
}
return false;
}
/* Remove any hidden declarations from a possibly overloaded set
of functions. */
tree
remove_hidden_names (tree fns)
{
if (!fns)
return fns;
if (DECL_P (fns) && hidden_name_p (fns))
fns = NULL_TREE;
else if (TREE_CODE (fns) == OVERLOAD)
{
tree o;
for (o = fns; o; o = OVL_NEXT (o))
if (hidden_name_p (OVL_CURRENT (o)))
break;
if (o)
{
tree n = NULL_TREE;
for (o = fns; o; o = OVL_NEXT (o))
if (!hidden_name_p (OVL_CURRENT (o)))
n = lookup_add (OVL_CURRENT (o), n);
fns = n;
}
}
return fns;
}
/* Suggest alternatives for NAME, an IDENTIFIER_NODE for which name /* Suggest alternatives for NAME, an IDENTIFIER_NODE for which name
lookup failed. Search through all available namespaces and print out lookup failed. Search through all available namespaces and print out
possible candidates. If no exact matches are found, and possible candidates. If no exact matches are found, and
...@@ -5337,10 +5280,6 @@ lookup_name_real_1 (tree name, int prefer_type, int nonclass, bool block_p, ...@@ -5337,10 +5280,6 @@ lookup_name_real_1 (tree name, int prefer_type, int nonclass, bool block_p,
if (!val) if (!val)
val = unqualified_namespace_lookup (name, flags); val = unqualified_namespace_lookup (name, flags);
/* Anticipated built-ins and friends aren't found by normal lookup. */
if (val && !(flags & LOOKUP_HIDDEN))
val = remove_hidden_names (val);
/* If we have a single function from a using decl, pull it out. */ /* If we have a single function from a using decl, pull it out. */
if (val && TREE_CODE (val) == OVERLOAD && !really_overloaded_fn (val)) if (val && TREE_CODE (val) == OVERLOAD && !really_overloaded_fn (val))
val = OVL_FUNCTION (val); val = OVL_FUNCTION (val);
......
...@@ -308,8 +308,6 @@ extern tree lookup_name_real (tree, int, int, bool, int, int); ...@@ -308,8 +308,6 @@ extern tree lookup_name_real (tree, int, int, bool, int, int);
extern tree lookup_type_scope (tree, tag_scope); extern tree lookup_type_scope (tree, tag_scope);
extern tree get_namespace_binding (tree ns, tree id); extern tree get_namespace_binding (tree ns, tree id);
extern void set_global_binding (tree id, tree val); extern void set_global_binding (tree id, tree val);
extern bool hidden_name_p (tree);
extern tree remove_hidden_names (tree);
extern tree lookup_qualified_name (tree, tree, int, bool, /*hidden*/bool = false); extern tree lookup_qualified_name (tree, tree, int, bool, /*hidden*/bool = false);
extern tree lookup_name_nonclass (tree); extern tree lookup_name_nonclass (tree);
extern tree lookup_name_innermost_nonclass_level (tree); extern tree lookup_name_innermost_nonclass_level (tree);
......
...@@ -2204,6 +2204,27 @@ ovl_insert (tree fn, tree maybe_ovl, bool using_p) ...@@ -2204,6 +2204,27 @@ ovl_insert (tree fn, tree maybe_ovl, bool using_p)
return result; return result;
} }
/* Skip any hidden names at the beginning of OVL. */
tree
ovl_skip_hidden (tree ovl)
{
for (;
ovl && TREE_CODE (ovl) == OVERLOAD && OVL_HIDDEN_P (ovl);
ovl = OVL_CHAIN (ovl))
gcc_checking_assert (DECL_HIDDEN_P (OVL_FUNCTION (ovl)));
if (ovl && TREE_CODE (ovl) != OVERLOAD && DECL_HIDDEN_P (ovl))
{
/* Any hidden functions should have been wrapped in an
overload, but injected friend classes will not. */
gcc_checking_assert (!DECL_DECLARES_FUNCTION_P (ovl));
ovl = NULL_TREE;
}
return ovl;
}
/* NODE is an OVL_HIDDEN_P node which is now revealed. */ /* NODE is an OVL_HIDDEN_P node which is now revealed. */
tree tree
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment