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
This commit is contained in:
Nathan Sidwell 2017-05-24 15:56:06 +00:00 committed by Nathan Sidwell
parent 657e5f8326
commit c0edbb32c1
5 changed files with 36 additions and 68 deletions

View file

@ -1,5 +1,14 @@
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.
(ovl_iterator::hidden_p, ovl_iterator::reveal_node): New.
(ovl_iterator::reveal_node): Declare.

View file

@ -6852,6 +6852,7 @@ extern tree ovl_make (tree fn,
tree next = NULL_TREE);
extern tree ovl_insert (tree fn, tree maybe_ovl,
bool using_p = false);
extern tree ovl_skip_hidden (tree);
extern tree lookup_add (tree fns, tree lookup);
extern void lookup_keep (tree lookup, bool keep);
extern int is_overloaded_fn (tree);

View file

@ -275,14 +275,10 @@ arg_assoc_namespace (struct arg_lookup *k, tree scope)
if (!value)
return false;
value = ovl_skip_hidden (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)))
return true;
}
@ -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
found so far. They will be added back by arg_assoc_class as
appropriate. */
fns = remove_hidden_names (fns);
fns = ovl_skip_hidden (fns);
k.name = name;
k.args = args;
@ -4347,7 +4343,7 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags)
/* Copy the type. */
type = new_binding->type;
if (LOOKUP_NAMESPACES_ONLY (flags)
|| (type && hidden_name_p (type) && !(flags & LOOKUP_HIDDEN)))
|| (type && !(flags & LOOKUP_HIDDEN) && DECL_HIDDEN_P (type)))
type = NULL_TREE;
/* Copy the value. */
@ -4355,7 +4351,7 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags)
if (val)
{
if (!(flags & LOOKUP_HIDDEN))
val = remove_hidden_names (val);
val = ovl_skip_hidden (val);
if (val)
switch (TREE_CODE (val))
{
@ -4465,59 +4461,6 @@ qualify_lookup (tree val, int flags)
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
lookup failed. Search through all available namespaces and print out
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,
if (!val)
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 (val && TREE_CODE (val) == OVERLOAD && !really_overloaded_fn (val))
val = OVL_FUNCTION (val);

View file

@ -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 get_namespace_binding (tree ns, tree id);
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_name_nonclass (tree);
extern tree lookup_name_innermost_nonclass_level (tree);

View file

@ -2204,6 +2204,27 @@ ovl_insert (tree fn, tree maybe_ovl, bool using_p)
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. */
tree