cp-tree.h (OVL_FIRST, OVL_NAME): New.

* 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
This commit is contained in:
Nathan Sidwell 2017-05-16 13:15:53 +00:00 committed by Nathan Sidwell
parent ba1a69079f
commit 848bf88da8
16 changed files with 64 additions and 54 deletions

View File

@ -1,5 +1,28 @@
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.

View File

@ -117,10 +117,9 @@ function_concept_check_p (tree t)
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;

View File

@ -626,6 +626,11 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
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;
@ -6668,6 +6673,13 @@ extern tree hash_tree_cons (tree, tree, tree);
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);

View File

@ -1722,7 +1722,7 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
int win = 0;
tree candidate;
tree cand = TREE_VALUE (conv);
cand = OVL_CURRENT (cand);
cand = OVL_FIRST (cand);
if (winner && winner == cand)
continue;

View File

@ -683,7 +683,7 @@ poplevel (int keep, int reverse, int functionbody)
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
@ -10104,10 +10104,7 @@ grokdeclarator (const cp_declarator *declarator,
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. */

View File

@ -5029,7 +5029,7 @@ mark_used (tree decl, tsubst_flags_t complain)
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. */

View File

@ -1208,7 +1208,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
/* 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:
@ -1235,10 +1235,8 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
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)
@ -2498,7 +2496,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
/* 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);
@ -3004,7 +3002,7 @@ location_of (tree t)
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);

View File

@ -494,8 +494,7 @@ do_friend (tree ctype, tree declarator, tree decl,
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)

View File

@ -2063,7 +2063,7 @@ build_offset_ref (tree type, tree member, bool address_p,
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. */

View File

@ -2833,8 +2833,7 @@ write_member_name (tree member)
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));
}
@ -3053,10 +3052,7 @@ write_expression (tree expr)
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);
@ -3257,7 +3253,7 @@ write_expression (tree expr)
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);
}

View File

@ -502,10 +502,8 @@ strip_inheriting_ctors (tree dfn)
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);

View File

@ -3610,7 +3610,6 @@ set_inherited_value_binding_p (cxx_binding *binding, tree decl,
bool
pushdecl_class_level (tree x)
{
tree name;
bool is_valid = true;
bool subtime;
@ -3621,10 +3620,7 @@ pushdecl_class_level (tree x)
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)
{

View File

@ -2930,7 +2930,7 @@ check_explicit_specialization (tree declarator,
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;
@ -3910,8 +3910,7 @@ check_template_shadow (tree decl)
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
@ -14128,7 +14127,7 @@ tsubst_baselink (tree baselink, tree object_type,
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);
@ -14150,7 +14149,7 @@ tsubst_baselink (tree baselink, tree object_type,
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. */

View File

@ -2231,15 +2231,10 @@ perform_koenig_lookup (cp_expr fn, vec<tree, va_gc> *args,
/* Find the name of the overloaded function. */
if (identifier_p (fn))
identifier = fn;
else if (is_overloaded_fn (fn))
else
{
functions = fn;
identifier = DECL_NAME (get_first_fn (functions));
}
else if (DECL_P (fn))
{
functions = fn;
identifier = DECL_NAME (fn);
identifier = OVL_NAME (functions);
}
/* A call to a namespace-scope function using an unqualified name.

View File

@ -2169,7 +2169,7 @@ get_fns (tree from)
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. */

View File

@ -2764,10 +2764,8 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p,
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)
@ -5746,7 +5744,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
/* Fall through. */
case OVERLOAD:
arg = OVL_CURRENT (arg);
arg = OVL_FIRST (arg);
break;
case OFFSET_REF: