From c844b3a0ed6ee62f4d41e3cab59e13edbd57c59c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 25 May 2011 10:35:00 -0400 Subject: 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 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 3 +++ gcc/cp/semantics.c | 3 ++- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5732150..5bc1748 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-05-25 Jason Merrill + 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 * pt.c (tsubst_decl) [PARM_DECL]: Handle partial instantiation of function parameter pack. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fc84314..bb4515b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 the class itself. This puts error messages involving generated implicit functions at a predictable point, and the same point diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 50f25f0..55ad117 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8145,7 +8145,8 @@ lambda_function (tree lambda) type = lambda; gcc_assert (LAMBDA_TYPE_P (type)); /* 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; lambda = lookup_member (type, ansi_opname (CALL_EXPR), /*protect=*/0, /*want_type=*/false); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9f13b0d..5d01971 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-05-25 Jason Merrill + * g++.dg/cpp0x/lambda/lambda-conv5.C: New. + * g++.dg/cpp0x/variadic109.C: New. 2011-05-25 H.J. Lu diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C new file mode 100644 index 0000000..53d8e99 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C @@ -0,0 +1,15 @@ +// PR c++/45080 +// { dg-options -std=c++0x } + +typedef void(*pfn)(); + +template +void f() +{ + pfn fn = []{}; +} + +void test() +{ + f(); +} -- cgit v1.1