Commit c844b3a0 by Jason Merrill Committed by Jason Merrill

re PR c++/45080 ([C++0x] Rejects lambda to function pointer conversion inside function template)

	PR c++/45080
	* pt.c (instantiate_class_template_1): Call maybe_add_lambda_conv_op.
	* semantics.c (lambda_function): Check COMPLETE_OR_OPEN_TYPE_P.

From-SVN: r174203
parent 7f0d79d5
2011-05-25 Jason Merrill <jason@redhat.com> 2011-05-25 Jason Merrill <jason@redhat.com>
PR c++/45080
* pt.c (instantiate_class_template_1): Call maybe_add_lambda_conv_op.
* semantics.c (lambda_function): Check COMPLETE_OR_OPEN_TYPE_P.
PR c++/48292 PR c++/48292
* pt.c (tsubst_decl) [PARM_DECL]: Handle partial instantiation of * pt.c (tsubst_decl) [PARM_DECL]: Handle partial instantiation of
function parameter pack. function parameter pack.
......
...@@ -8566,6 +8566,9 @@ instantiate_class_template_1 (tree type) ...@@ -8566,6 +8566,9 @@ instantiate_class_template_1 (tree type)
} }
} }
if (CLASSTYPE_LAMBDA_EXPR (type))
maybe_add_lambda_conv_op (type);
/* Set the file and line number information to whatever is given for /* Set the file and line number information to whatever is given for
the class itself. This puts error messages involving generated the class itself. This puts error messages involving generated
implicit functions at a predictable point, and the same point implicit functions at a predictable point, and the same point
......
...@@ -8145,7 +8145,8 @@ lambda_function (tree lambda) ...@@ -8145,7 +8145,8 @@ lambda_function (tree lambda)
type = lambda; type = lambda;
gcc_assert (LAMBDA_TYPE_P (type)); gcc_assert (LAMBDA_TYPE_P (type));
/* Don't let debug_tree cause instantiation. */ /* Don't let debug_tree cause instantiation. */
if (CLASSTYPE_TEMPLATE_INSTANTIATION (type) && !COMPLETE_TYPE_P (type)) if (CLASSTYPE_TEMPLATE_INSTANTIATION (type)
&& !COMPLETE_OR_OPEN_TYPE_P (type))
return NULL_TREE; return NULL_TREE;
lambda = lookup_member (type, ansi_opname (CALL_EXPR), lambda = lookup_member (type, ansi_opname (CALL_EXPR),
/*protect=*/0, /*want_type=*/false); /*protect=*/0, /*want_type=*/false);
......
2011-05-25 Jason Merrill <jason@redhat.com> 2011-05-25 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/lambda/lambda-conv5.C: New.
* g++.dg/cpp0x/variadic109.C: New. * g++.dg/cpp0x/variadic109.C: New.
2011-05-25 H.J. Lu <hongjiu.lu@intel.com> 2011-05-25 H.J. Lu <hongjiu.lu@intel.com>
......
// PR c++/45080
// { dg-options -std=c++0x }
typedef void(*pfn)();
template<typename=int>
void f()
{
pfn fn = []{};
}
void test()
{
f();
}
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