2015-10-22 Jason Merrill <jason@redhat.com>
+ * call.c (add_template_conv_candidate): Pass DEDUCE_CALL.
+ (add_template_candidate_real): Handle it.
+ (fn_type_unification): Handle it.
+
* call.c (add_conv_candidate): Remove first_arg parm.
(add_template_conv_candidate): Likewise.
(add_template_candidate_real): Don't pass it.
{
if (first_arg_without_in_chrg != NULL_TREE)
first_arg_without_in_chrg = NULL_TREE;
+ else if (return_type && strict == DEDUCE_CALL)
+ /* We're deducing for a call to the result of a template conversion
+ function, so the args don't contain 'this'; leave them alone. */;
else
++skip_without_in_chrg;
}
flags, NULL_TREE, strict, complain);
}
+/* Create an overload candidate for the conversion function template TMPL,
+ returning RETURN_TYPE, which will be invoked for expression OBJ to produce a
+ pointer-to-function which will in turn be called with the argument list
+ ARGLIST, and add it to CANDIDATES. This does not change ARGLIST. FLAGS is
+ passed on to implicit_conversion. */
static struct z_candidate *
add_template_conv_candidate (struct z_candidate **candidates, tree tmpl,
return
add_template_candidate_real (candidates, tmpl, NULL_TREE, NULL_TREE,
NULL_TREE, arglist, return_type, access_path,
- conversion_path, 0, obj, DEDUCE_CONV,
+ conversion_path, 0, obj, DEDUCE_CALL,
complain);
}
DEDUCE_CALL:
We are deducing arguments for a function call, as in
- [temp.deduct.call].
+ [temp.deduct.call]. If RETURN_TYPE is non-null, we are
+ deducing arguments for a call to the result of a conversion
+ function template, as in [over.call.object].
DEDUCE_CONV:
We are deducing arguments for a conversion function, as in
/* Never do unification on the 'this' parameter. */
parms = skip_artificial_parms_for (fn, TYPE_ARG_TYPES (fntype));
- if (return_type)
+ if (return_type && strict == DEDUCE_CALL)
+ {
+ /* We're deducing for a call to the result of a template conversion
+ function. The parms we really want are in return_type. */
+ if (POINTER_TYPE_P (return_type))
+ return_type = TREE_TYPE (return_type);
+ parms = TYPE_ARG_TYPES (return_type);
+ }
+ else if (return_type)
{
tree *new_args;