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> 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, * cp-tree.h (build_this_parm, cp_build_parm_decl,
build_artificial_parm): Add FN parm. build_artificial_parm): Add FN parm.
* decl.c (start_cleanup_fn): Adjust. * decl.c (start_cleanup_fn): Adjust.
......
...@@ -14215,33 +14215,29 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -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 /* tsubst a BASELINK. OBJECT_TYPE, if non-NULL, is the type of the
type of the expression on the left-hand side of the "." or "->" expression on the left-hand side of the "." or "->" operator. A
operator. */ 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 static tree
tsubst_baselink (tree baselink, tree object_type, tsubst_baselink (tree baselink, tree object_type,
tree args, tsubst_flags_t complain, tree in_decl) 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); bool qualified = BASELINK_QUALIFIED_P (baselink);
/* A baselink indicates a function from a base class. Both the tree qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink));
BASELINK_ACCESS_BINFO and the base class referenced may qualifying_scope = tsubst (qualifying_scope, args, complain, in_decl);
indicate bases of the template class, rather than the
instantiated class. In addition, lookups that were not tree optype = BASELINK_OPTYPE (baselink);
ambiguous before may be ambiguous now. Therefore, we perform optype = tsubst (optype, args, complain, in_decl);
the lookup again. */
qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink)); tree template_args = NULL_TREE;
qualifying_scope = tsubst (qualifying_scope, args, bool template_id_p = false;
complain, in_decl); tree fns = BASELINK_FUNCTIONS (baselink);
fns = BASELINK_FUNCTIONS (baselink);
optype = tsubst (BASELINK_OPTYPE (baselink), args, complain, in_decl);
if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
{ {
template_id_p = true; template_id_p = true;
...@@ -14251,41 +14247,40 @@ tsubst_baselink (tree baselink, tree object_type, ...@@ -14251,41 +14247,40 @@ tsubst_baselink (tree baselink, tree object_type,
template_args = tsubst_template_args (template_args, args, template_args = tsubst_template_args (template_args, args,
complain, in_decl); complain, in_decl);
} }
name = OVL_NAME (fns);
tree name = OVL_NAME (fns);
if (IDENTIFIER_TYPENAME_P (name)) if (IDENTIFIER_TYPENAME_P (name))
name = mangle_conv_op_name_for_type (optype); name = mangle_conv_op_name_for_type (optype);
baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1); baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1);
if (!baselink) if (!baselink)
{ {
if (constructor_name_p (name, qualifying_scope)) if ((complain & tf_error) && constructor_name_p (name, qualifying_scope))
{
if (complain & tf_error)
error ("cannot call constructor %<%T::%D%> directly", error ("cannot call constructor %<%T::%D%> directly",
qualifying_scope, name); qualifying_scope, name);
}
return error_mark_node; return error_mark_node;
} }
/* If lookup found a single function, mark it as used at this /* If lookup found a single function, mark it as used at this point.
point. (If it lookup found multiple functions the one selected (If it lookup found multiple functions the one selected later by
later by overload resolution will be marked as used at that overload resolution will be marked as used at that point.) */
point.) */
if (BASELINK_P (baselink)) if (BASELINK_P (baselink))
fns = BASELINK_FUNCTIONS (baselink); fns = BASELINK_FUNCTIONS (baselink);
if (!template_id_p && !really_overloaded_fn (fns) if (!template_id_p && !really_overloaded_fn (fns)
&& !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error)) && !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error))
return error_mark_node; return error_mark_node;
if (BASELINK_P (baselink))
{
/* Add back the template arguments, if present. */ /* Add back the template arguments, if present. */
if (BASELINK_P (baselink) && template_id_p) if (template_id_p)
BASELINK_FUNCTIONS (baselink) BASELINK_FUNCTIONS (baselink)
= build2 (TEMPLATE_ID_EXPR, = build2 (TEMPLATE_ID_EXPR, unknown_type_node,
unknown_type_node, BASELINK_FUNCTIONS (baselink), template_args);
BASELINK_FUNCTIONS (baselink),
template_args);
/* Update the conversion operator type. */ /* Update the conversion operator type. */
if (BASELINK_P (baselink))
BASELINK_OPTYPE (baselink) = optype; BASELINK_OPTYPE (baselink) = optype;
}
if (!object_type) if (!object_type)
object_type = current_class_type; object_type = current_class_type;
...@@ -14301,6 +14296,7 @@ tsubst_baselink (tree baselink, tree object_type, ...@@ -14301,6 +14296,7 @@ tsubst_baselink (tree baselink, tree object_type,
so that we still get virtual function binding. */ so that we still get virtual function binding. */
BASELINK_QUALIFIED_P (baselink) = false; BASELINK_QUALIFIED_P (baselink) = false;
} }
return baselink; 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