* cp-tree.h (lookup_add): Swap args.
(ovl_cons, build_overload): Delete.
* name-lookup.c (add_function, push_overloaded_decl_1)
do_nonmember_using_decl, merge_functions, remove_hidden_names):
Use lookup_add, ovl_insert.
* pt.c (check_explicit_specialization): Use lookup_add.
(do_class_deduction): Likewise. Refactor if.
* tree.c (lookup_add): Swap args.
(ovl_cons, build_overload): Delete.
(--This line, and those below, will be ignored--
M cp/cp-tree.h
M cp/name-lookup.c
M cp/pt.c
M cp/ChangeLog
M cp/tree.c
From-SVN: r248198
2017-05-18 Nathan Sidwell <nathan@acm.org>
+ * cp-tree.h (lookup_add): Swap args.
+ (ovl_cons, build_overload): Delete.
+ * name-lookup.c (add_function, push_overloaded_decl_1,
+ do_nonmember_using_decl, merge_functions, remove_hidden_names):
+ Use lookup_add, ovl_insert.
+ * pt.c (check_explicit_specialization): Use lookup_add.
+ (do_class_deduction): Likewise. Refactor if.
+ * tree.c (lookup_add): Swap args.
+ (ovl_cons, build_overload): Delete.
+
* name-lookup.c (find_local_binding): New, broken out of ...
(lookup_name_innermost_nonclass_level_1): ... here. Call it.
(set_namespace_binding): Swap scope & name args.
tree next = NULL_TREE);
extern tree ovl_insert (tree fn, tree maybe_ovl,
bool using_p = false);
-extern tree lookup_add (tree lookup, tree ovl);
+extern tree lookup_add (tree fns, tree lookup);
extern int is_overloaded_fn (tree);
extern tree dependent_name (tree);
extern tree get_fns (tree) ATTRIBUTE_PURE;
extern tree get_first_fn (tree) ATTRIBUTE_PURE;
-extern tree ovl_cons (tree, tree);
-extern tree build_overload (tree, tree);
extern tree ovl_scope (tree);
extern const char *cxx_printable_name (tree, int);
extern const char *cxx_printable_name_translate (tree, int);
;
else
{
- k->functions = build_overload (fn, k->functions);
+ k->functions = lookup_add (fn, k->functions);
if (TREE_CODE (k->functions) == OVERLOAD)
OVL_ARG_DEPENDENT (k->functions) = true;
}
}
}
- if (old || TREE_CODE (decl) == TEMPLATE_DECL
- /* If it's a using declaration, we always need to build an OVERLOAD,
- because it's the only way to remember that the declaration comes
- from 'using', and have the lookup behave correctly. */
- || (flags & PUSH_USING))
- {
- if (old && TREE_CODE (old) != OVERLOAD)
- /* Wrap the existing single decl in an overload. */
- new_binding = ovl_cons (old, NULL_TREE);
- else
- new_binding = old;
- new_binding = ovl_cons (decl, new_binding);
- if (flags & PUSH_USING)
- OVL_USED (new_binding) = 1;
- }
- else
- /* NAME is not ambiguous. */
- new_binding = decl;
+ new_binding = ovl_insert (decl, old, flags & PUSH_USING);
if (doing_global)
set_namespace_binding (current_namespace, name, new_binding);
if (*newval && TREE_CODE (*newval) == OVERLOAD)
TREE_TYPE (*newval) = unknown_type_node;
/* Add this new function to the set. */
- *newval = build_overload (OVL_CURRENT (tmp), *newval);
- /* If there is only one function, then we use its type. (A
- using-declaration naming a single function can be used in
- contexts where overload resolution cannot be
- performed.) */
- if (TREE_CODE (*newval) != OVERLOAD)
- {
- *newval = ovl_cons (*newval, NULL_TREE);
- TREE_TYPE (*newval) = TREE_TYPE (OVL_CURRENT (tmp));
- }
- OVL_USED (*newval) = 1;
+ *newval = ovl_insert (OVL_CURRENT (tmp), *newval, true);
}
}
else
/* If we exhausted all of the functions in S1, FN2 is new. */
if (!fns1)
- s1 = build_overload (fn2, s1);
+ s1 = lookup_add (fn2, s1);
}
return s1;
}
for (o = fns; o; o = OVL_NEXT (o))
if (!hidden_name_p (OVL_CURRENT (o)))
- n = build_overload (OVL_CURRENT (o), n);
+ n = lookup_add (OVL_CURRENT (o), n);
fns = n;
}
}
/* Glue all these conversion functions together
with those we already have. */
for (; ovl; ovl = OVL_NEXT (ovl))
- fns = ovl_cons (OVL_CURRENT (ovl), fns);
+ fns = lookup_add (OVL_CURRENT (ovl), fns);
}
}
tree pruned = NULL_TREE;
for (lkp_iterator iter (cands); iter; ++iter)
if (!DECL_NONCONVERTING_P (STRIP_TEMPLATE (*iter)))
- pruned = lookup_add (pruned, *iter);
+ pruned = lookup_add (*iter, pruned);
cands = pruned;
}
&& DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide)))
elided = true;
else
- cands = lookup_add (cands, guide);
+ cands = lookup_add (guide, cands);
saw_ctor = true;
}
- if (!saw_ctor && args->length() == 0)
+ if (args->length () < 2)
{
- tree guide = build_deduction_guide (type, outer_args, complain);
- if ((flags & LOOKUP_ONLYCONVERTING)
- && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide)))
- elided = true;
- else
- cands = lookup_add (cands, guide);
- }
- if (args->length() == 1)
- {
- tree guide = build_deduction_guide (build_reference_type (type),
- outer_args, complain);
- if ((flags & LOOKUP_ONLYCONVERTING)
- && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide)))
- elided = true;
- else
- cands = lookup_add (cands, guide);
+ tree gtype = NULL_TREE;
+
+ if (args->length () == 1)
+ gtype = build_reference_type (type);
+ else if (!saw_ctor)
+ gtype = type;
+
+ if (gtype)
+ {
+ tree guide = build_deduction_guide (gtype, outer_args, complain);
+ if ((flags & LOOKUP_ONLYCONVERTING)
+ && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide)))
+ elided = true;
+ else
+ cands = lookup_add (guide, cands);
+ }
}
if (elided && !cands)
return overload;
}
-/* Add a potential overload into a lookup set. */
+/* Add a set of new FNS into a lookup. */
tree
-lookup_add (tree lookup, tree ovl)
+lookup_add (tree fns, tree lookup)
{
- if (lookup || TREE_CODE (ovl) == TEMPLATE_DECL)
+ if (lookup || TREE_CODE (fns) == TEMPLATE_DECL)
{
- lookup = ovl_make (ovl, lookup);
+ lookup = ovl_make (fns, lookup);
OVL_LOOKUP_P (lookup) = true;
}
else
- lookup = ovl;
+ lookup = fns;
return lookup;
}
return OVL_FIRST (get_fns (from));
}
-/* Return a new OVL node, concatenating it with the old one. */
-
-tree
-ovl_cons (tree decl, tree chain)
-{
- tree result = make_node (OVERLOAD);
- TREE_TYPE (result) = unknown_type_node;
- OVL_FUNCTION (result) = decl;
- TREE_CHAIN (result) = chain;
-
- return result;
-}
-
-/* Build a new overloaded function. If this is the first one,
- just return it; otherwise, ovl_cons the _DECLs */
-
-tree
-build_overload (tree decl, tree chain)
-{
- if (! chain && TREE_CODE (decl) != TEMPLATE_DECL)
- return decl;
- return ovl_cons (decl, chain);
-}
-
/* Return the scope where the overloaded functions OVL were found. */
tree