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.
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;
}
/* 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;
/* 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. */
if (val)
{
if (!(flags & LOOKUP_HIDDEN))
- val = remove_hidden_names (val);
+ val = ovl_skip_hidden (val);
if (val)
switch (TREE_CODE (val))
{
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
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);
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);
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