* cp-tree.h (OVL_FIRST, OVL_NAME): New.
(ovl_first): New.
* constexpr.c (function_concept_check): Use OVL_FIRST.
* cvt.c (build_expr_type_conversion): Likewise.
* decl.c (poplevel, grokdeclarator): Use OVL_NAME.
* decl2.c (mark_used): Use OVL_FIRST.
* error.c (dump_decl): Use OVL_FIRST, OVL_NAME.
(dump_expr, location_of): Use OVL_FIRST.
* friend.c (do_friend): Use OVL_NAME.
* init.c (build_offset_ref): Use OVL_FIRST.
* mangle.c (write_member_name): Likewise.
(write_expression): Use OVL_NAME.
* method.c (strip_inheriting_ctors): Use OVL_FIRST.
* name-lookup.c (pushdecl_class_level): Use OVL_NAME.
* pt.c (check_explicit_specialization): Use OVL_FIRST.
(check_template_shadow): Likewise.
(tsubst_template_args): Use OVL_NAME.
(tsubst_baselink): Use OVL_FIRST.
* semantics.c (perform_koenig_lookup): Use OVL_NAME.
* tree.c (get_first_fn): Use OVL_FIRST.
* typeck.c (finish_class_member_access_expr): Use OVL_NAME.
(cp_build_addr_expr_1): Use OVL_FIRST.
From-SVN: r248108
2017-05-16 Nathan Sidwell <nathan@acm.org>
+ * cp-tree.h (OVL_FIRST, OVL_NAME): New.
+ (ovl_first): New.
+ * constexpr.c (function_concept_check): Use OVL_FIRST.
+ * cvt.c (build_expr_type_conversion): Likewise.
+ * decl.c (poplevel, grokdeclarator): Use OVL_NAME.
+ * decl2.c (mark_used): Use OVL_FIRST.
+ * error.c (dump_decl): Use OVL_FIRST, OVL_NAME.
+ (dump_expr, location_of): Use OVL_FIRST.
+ * friend.c (do_friend): Use OVL_NAME.
+ * init.c (build_offset_ref): Use OVL_FIRST.
+ * mangle.c (write_member_name): Likewise.
+ (write_expression): Use OVL_NAME.
+ * method.c (strip_inheriting_ctors): Use OVL_FIRST.
+ * name-lookup.c (pushdecl_class_level): Use OVL_NAME.
+ * pt.c (check_explicit_specialization): Use OVL_FIRST.
+ (check_template_shadow): Likewise.
+ (tsubst_template_args): Use OVL_NAME.
+ (tsubst_baselink): Use OVL_FIRST.
+ * semantics.c (perform_koenig_lookup): Use OVL_NAME.
+ * tree.c (get_first_fn): Use OVL_FIRST.
+ * typeck.c (finish_class_member_access_expr): Use OVL_NAME.
+ (cp_build_addr_expr_1): Use OVL_FIRST.
+
* pt.c (tsubst_copy_and_build): Remove unnecessary COMPONENT_REF
peeking.
* semantics.c (finish_id_expression): Directly init local var.
gcc_assert (TREE_CODE (t) == CALL_EXPR);
tree fn = CALL_EXPR_FN (t);
if (fn != NULL_TREE
- && TREE_CODE (fn) == TEMPLATE_ID_EXPR
- && TREE_CODE (TREE_OPERAND (fn, 0)) == OVERLOAD)
+ && TREE_CODE (fn) == TEMPLATE_ID_EXPR)
{
- tree f1 = get_first_fn (fn);
+ tree f1 = OVL_FIRST (TREE_OPERAND (fn, 0));
if (TREE_CODE (f1) == TEMPLATE_DECL
&& DECL_DECLARED_CONCEPT_P (DECL_TEMPLATE_RESULT (f1)))
return true;
and can be freed afterward. */
#define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
+/* The first decl of an overload. */
+#define OVL_FIRST(NODE) ovl_first (NODE)
+/* The name of the overload set. */
+#define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE))
+
struct GTY(()) tree_overload {
struct tree_common common;
tree function;
extern tree hash_tree_chain (tree, tree);
extern tree build_qualified_name (tree, tree, tree, bool);
extern tree build_ref_qualified_type (tree, cp_ref_qualifier);
+inline tree
+ovl_first (tree node)
+{
+ while (TREE_CODE (node) == OVERLOAD)
+ node = OVL_FUNCTION (node);
+ return node;
+}
extern int is_overloaded_fn (tree);
extern tree dependent_name (tree);
extern tree get_fns (tree);
int win = 0;
tree candidate;
tree cand = TREE_VALUE (conv);
- cand = OVL_CURRENT (cand);
+ cand = OVL_FIRST (cand);
if (winner && winner == cand)
continue;
for (link = decls; link; link = TREE_CHAIN (link))
{
decl = TREE_CODE (link) == TREE_LIST ? TREE_VALUE (link) : link;
- tree name = DECL_NAME (OVL_CURRENT (decl));
+ tree name = OVL_NAME (decl);
if (leaving_for_scope && VAR_P (decl)
/* It's hard to make this ARM compatibility hack play nicely with
if (variable_template_p (dname))
dname = DECL_NAME (dname);
else
- {
- gcc_assert (is_overloaded_fn (dname));
- dname = DECL_NAME (get_first_fn (dname));
- }
+ dname = OVL_NAME (dname);
}
}
/* Fall through. */
decl = BASELINK_FUNCTIONS (decl);
if (really_overloaded_fn (decl))
return true;
- decl = OVL_CURRENT (decl);
+ decl = OVL_FIRST (decl);
}
/* Set TREE_USED for the benefit of -Wunused. */
/* If there's only one function, just treat it like an ordinary
FUNCTION_DECL. */
- t = OVL_CURRENT (t);
+ t = OVL_FIRST (t);
/* Fall through. */
case FUNCTION_DECL:
tree name = TREE_OPERAND (t, 0);
tree args = TREE_OPERAND (t, 1);
- if (is_overloaded_fn (name))
- name = get_first_fn (name);
- if (DECL_P (name))
- name = DECL_NAME (name);
+ if (!identifier_p (name))
+ name = OVL_NAME (name);
dump_decl (pp, name, flags);
pp_cxx_begin_template_argument_list (pp);
if (args == error_mark_node)
/* A::f */
dump_expr (pp, t, flags | TFF_EXPR_IN_PARENS);
else if (BASELINK_P (t))
- dump_expr (pp, OVL_CURRENT (BASELINK_FUNCTIONS (t)),
+ dump_expr (pp, OVL_FIRST (BASELINK_FUNCTIONS (t)),
flags | TFF_EXPR_IN_PARENS);
else
dump_decl (pp, t, flags);
return input_location;
}
else if (TREE_CODE (t) == OVERLOAD)
- t = OVL_FUNCTION (t);
+ t = OVL_FIRST (t);
if (DECL_P (t))
return DECL_SOURCE_LOCATION (t);
if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR)
{
declarator = TREE_OPERAND (declarator, 0);
- if (is_overloaded_fn (declarator))
- declarator = DECL_NAME (get_first_fn (declarator));
+ declarator = OVL_NAME (declarator);
}
if (ctype)
if (TREE_CODE (t) != TEMPLATE_ID_EXPR && !really_overloaded_fn (t))
{
/* Get rid of a potential OVERLOAD around it. */
- t = OVL_CURRENT (t);
+ t = OVL_FIRST (t);
/* Unique functions are handled easily. */
else if (TREE_CODE (member) == TEMPLATE_ID_EXPR)
{
tree name = TREE_OPERAND (member, 0);
- if (TREE_CODE (name) == OVERLOAD)
- name = OVL_FUNCTION (name);
+ name = OVL_FIRST (name);
write_member_name (name);
write_template_args (TREE_OPERAND (member, 1));
}
else if (TREE_CODE (expr) == TEMPLATE_ID_EXPR)
{
tree fn = TREE_OPERAND (expr, 0);
- if (is_overloaded_fn (fn))
- fn = get_first_fn (fn);
- if (DECL_P (fn))
- fn = DECL_NAME (fn);
+ fn = OVL_NAME (fn);
if (IDENTIFIER_OPNAME_P (fn))
write_string ("on");
write_unqualified_id (fn);
if ((TREE_CODE (fn) == FUNCTION_DECL
|| TREE_CODE (fn) == OVERLOAD)
&& type_dependent_expression_p_push (expr))
- fn = DECL_NAME (get_first_fn (fn));
+ fn = OVL_NAME (fn);
write_expression (fn);
}
return dfn;
tree fn = dfn;
while (tree inh = DECL_INHERITED_CTOR (fn))
- {
- inh = OVL_CURRENT (inh);
- fn = inh;
- }
+ fn = OVL_FIRST (inh);
+
if (TREE_CODE (fn) == TEMPLATE_DECL
&& TREE_CODE (dfn) == FUNCTION_DECL)
fn = DECL_TEMPLATE_RESULT (fn);
bool
pushdecl_class_level (tree x)
{
- tree name;
bool is_valid = true;
bool subtime;
subtime = timevar_cond_start (TV_NAME_LOOKUP);
/* Get the name of X. */
- if (TREE_CODE (x) == OVERLOAD)
- name = DECL_NAME (get_first_fn (x));
- else
- name = DECL_NAME (x);
+ tree name = OVL_NAME (x);
if (name)
{
methods->iterate (idx, &ovl);
++idx)
{
- if (!DECL_CONV_FN_P (OVL_CURRENT (ovl)))
+ if (!DECL_CONV_FN_P (OVL_FIRST (ovl)))
/* There are no more conversion functions. */
break;
return true;
/* Figure out what we're shadowing. */
- if (TREE_CODE (decl) == OVERLOAD)
- decl = OVL_CURRENT (decl);
+ decl = OVL_FIRST (decl);
olddecl = innermost_non_namespace_value (DECL_NAME (decl));
/* If there's no previous binding for this name, we're not shadowing
template_args = tsubst_template_args (template_args, args,
complain, in_decl);
}
- name = DECL_NAME (get_first_fn (fns));
+ name = OVL_NAME (fns);
if (IDENTIFIER_TYPENAME_P (name))
name = mangle_conv_op_name_for_type (optype);
baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1);
if (BASELINK_P (baselink))
fns = BASELINK_FUNCTIONS (baselink);
if (!template_id_p && !really_overloaded_fn (fns)
- && !mark_used (OVL_CURRENT (fns), complain) && !(complain & tf_error))
+ && !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error))
return error_mark_node;
/* Add back the template arguments, if present. */
/* Find the name of the overloaded function. */
if (identifier_p (fn))
identifier = fn;
- else if (is_overloaded_fn (fn))
- {
- functions = fn;
- identifier = DECL_NAME (get_first_fn (functions));
- }
- else if (DECL_P (fn))
+ else
{
functions = fn;
- identifier = DECL_NAME (fn);
+ identifier = OVL_NAME (functions);
}
/* A call to a namespace-scope function using an unqualified name.
tree
get_first_fn (tree from)
{
- return OVL_CURRENT (get_fns (from));
+ return OVL_FIRST (get_fns (from));
}
/* Return a new OVL node, concatenating it with the old one. */
template_args = TREE_OPERAND (name, 1);
name = TREE_OPERAND (name, 0);
- if (TREE_CODE (name) == OVERLOAD)
- name = DECL_NAME (get_first_fn (name));
- else if (DECL_P (name))
- name = DECL_NAME (name);
+ if (!identifier_p (name))
+ name = OVL_NAME (name);
}
if (scope)
/* Fall through. */
case OVERLOAD:
- arg = OVL_CURRENT (arg);
+ arg = OVL_FIRST (arg);
break;
case OFFSET_REF: