Commit 4086ef7d by Nathan Sidwell Committed by Nathan Sidwell

* pt.c (tsubst_baselink): Fix & clarify formatting.

From-SVN: r249273
parent 56960fd6
2017-06-16 Nathan Sidwell <nathan@acm.org>
* pt.c (tsubst_baselink): Fix & clarify formatting.
* cp-tree.h (build_this_parm, cp_build_parm_decl,
build_artificial_parm): Add FN parm.
* decl.c (start_cleanup_fn): Adjust.
......
......@@ -14215,33 +14215,29 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
}
}
/* Like tsubst_expr for a BASELINK. OBJECT_TYPE, if non-NULL, is the
type of the expression on the left-hand side of the "." or "->"
operator. */
/* tsubst a BASELINK. OBJECT_TYPE, if non-NULL, is the type of the
expression on the left-hand side of the "." or "->" operator. A
baselink indicates a function from a base class. Both the
BASELINK_ACCESS_BINFO and the base class referenced may indicate
bases of the template class, rather than the instantiated class.
In addition, lookups that were not ambiguous before may be
ambiguous now. Therefore, we perform the lookup again. */
static tree
tsubst_baselink (tree baselink, tree object_type,
tree args, tsubst_flags_t complain, tree in_decl)
{
tree name;
tree qualifying_scope;
tree fns;
tree optype;
tree template_args = 0;
bool template_id_p = false;
bool qualified = BASELINK_QUALIFIED_P (baselink);
/* A baselink indicates a function from a base class. Both the
BASELINK_ACCESS_BINFO and the base class referenced may
indicate bases of the template class, rather than the
instantiated class. In addition, lookups that were not
ambiguous before may be ambiguous now. Therefore, we perform
the lookup again. */
qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink));
qualifying_scope = tsubst (qualifying_scope, args,
complain, in_decl);
fns = BASELINK_FUNCTIONS (baselink);
optype = tsubst (BASELINK_OPTYPE (baselink), args, complain, in_decl);
tree qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink));
qualifying_scope = tsubst (qualifying_scope, args, complain, in_decl);
tree optype = BASELINK_OPTYPE (baselink);
optype = tsubst (optype, args, complain, in_decl);
tree template_args = NULL_TREE;
bool template_id_p = false;
tree fns = BASELINK_FUNCTIONS (baselink);
if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
{
template_id_p = true;
......@@ -14251,41 +14247,40 @@ tsubst_baselink (tree baselink, tree object_type,
template_args = tsubst_template_args (template_args, args,
complain, in_decl);
}
name = OVL_NAME (fns);
tree 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)
{
if (constructor_name_p (name, qualifying_scope))
{
if (complain & tf_error)
if ((complain & tf_error) && constructor_name_p (name, qualifying_scope))
error ("cannot call constructor %<%T::%D%> directly",
qualifying_scope, name);
}
return error_mark_node;
}
/* If lookup found a single function, mark it as used at this
point. (If it lookup found multiple functions the one selected
later by overload resolution will be marked as used at that
point.) */
/* If lookup found a single function, mark it as used at this point.
(If it lookup found multiple functions the one selected later by
overload resolution will be marked as used at that point.) */
if (BASELINK_P (baselink))
fns = BASELINK_FUNCTIONS (baselink);
if (!template_id_p && !really_overloaded_fn (fns)
&& !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error))
return error_mark_node;
if (BASELINK_P (baselink))
{
/* Add back the template arguments, if present. */
if (BASELINK_P (baselink) && template_id_p)
if (template_id_p)
BASELINK_FUNCTIONS (baselink)
= build2 (TEMPLATE_ID_EXPR,
unknown_type_node,
BASELINK_FUNCTIONS (baselink),
template_args);
= build2 (TEMPLATE_ID_EXPR, unknown_type_node,
BASELINK_FUNCTIONS (baselink), template_args);
/* Update the conversion operator type. */
if (BASELINK_P (baselink))
BASELINK_OPTYPE (baselink) = optype;
}
if (!object_type)
object_type = current_class_type;
......@@ -14301,6 +14296,7 @@ tsubst_baselink (tree baselink, tree object_type,
so that we still get virtual function binding. */
BASELINK_QUALIFIED_P (baselink) = false;
}
return baselink;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment