Commit ba2b189e by Jason Merrill Committed by Jason Merrill

call.c (add_template_conv_candidate): Pass DEDUCE_CALL.

	* call.c (add_template_conv_candidate): Pass DEDUCE_CALL.
	(add_template_candidate_real): Handle it.
	(fn_type_unification): Handle it.

From-SVN: r229210
parent d4db5060
2015-10-22 Jason Merrill <jason@redhat.com> 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. * call.c (add_conv_candidate): Remove first_arg parm.
(add_template_conv_candidate): Likewise. (add_template_conv_candidate): Likewise.
(add_template_candidate_real): Don't pass it. (add_template_candidate_real): Don't pass it.
......
...@@ -3027,6 +3027,9 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl, ...@@ -3027,6 +3027,9 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
{ {
if (first_arg_without_in_chrg != NULL_TREE) if (first_arg_without_in_chrg != NULL_TREE)
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 else
++skip_without_in_chrg; ++skip_without_in_chrg;
} }
...@@ -3167,6 +3170,11 @@ add_template_candidate (struct z_candidate **candidates, tree tmpl, tree ctype, ...@@ -3167,6 +3170,11 @@ add_template_candidate (struct z_candidate **candidates, tree tmpl, tree ctype,
flags, NULL_TREE, strict, complain); 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 * static struct z_candidate *
add_template_conv_candidate (struct z_candidate **candidates, tree tmpl, add_template_conv_candidate (struct z_candidate **candidates, tree tmpl,
...@@ -3178,7 +3186,7 @@ add_template_conv_candidate (struct z_candidate **candidates, tree tmpl, ...@@ -3178,7 +3186,7 @@ add_template_conv_candidate (struct z_candidate **candidates, tree tmpl,
return return
add_template_candidate_real (candidates, tmpl, NULL_TREE, NULL_TREE, add_template_candidate_real (candidates, tmpl, NULL_TREE, NULL_TREE,
NULL_TREE, arglist, return_type, access_path, NULL_TREE, arglist, return_type, access_path,
conversion_path, 0, obj, DEDUCE_CONV, conversion_path, 0, obj, DEDUCE_CALL,
complain); complain);
} }
......
...@@ -17235,7 +17235,9 @@ pack_deducible_p (tree parm, tree fn) ...@@ -17235,7 +17235,9 @@ pack_deducible_p (tree parm, tree fn)
DEDUCE_CALL: DEDUCE_CALL:
We are deducing arguments for a function call, as in 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: DEDUCE_CONV:
We are deducing arguments for a conversion function, as in We are deducing arguments for a conversion function, as in
...@@ -17402,7 +17404,15 @@ fn_type_unification (tree fn, ...@@ -17402,7 +17404,15 @@ fn_type_unification (tree fn,
/* Never do unification on the 'this' parameter. */ /* Never do unification on the 'this' parameter. */
parms = skip_artificial_parms_for (fn, TYPE_ARG_TYPES (fntype)); 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; tree *new_args;
......
// { dg-do compile { target c++11 } }
template <class T>
using Fn = void (*)(T);
struct A
{
template <class T>
operator Fn<T>();
};
int main()
{
A()(42);
}
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