re PR c++/45080 ([C++0x] Rejects lambda to function pointer conversion inside functio...
authorJason Merrill <jason@redhat.com>
Wed, 25 May 2011 14:35:00 +0000 (10:35 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 25 May 2011 14:35:00 +0000 (10:35 -0400)
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
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C [new file with mode: 0644]

index 57321507c8109d36733b201d9f1f8e162d1e8a99..5bc1748d32db6c2dae6168afea93e407c24d0d52 100644 (file)
@@ -1,5 +1,9 @@
 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
        * pt.c (tsubst_decl) [PARM_DECL]: Handle partial instantiation of
        function parameter pack.
index fc84314daafde4a07d416001ee997f32b247cad4..bb4515be6b7f891774743e00408a22ff5598d382 100644 (file)
@@ -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
index 50f25f0f72d39c3a7ac98905f98897d83de1c732..55ad117880381127ed6e28a3bbdb299ab3391f8e 100644 (file)
@@ -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);
index 9f13b0d757357d2f6bd52b32200552eff1db215c..5d01971c3037abd71b64c7d6dabc7ff2adc9a84d 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/lambda/lambda-conv5.C: New.
+
        * g++.dg/cpp0x/variadic109.C: New.
 
 2011-05-25  H.J. Lu  <hongjiu.lu@intel.com>
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 (file)
index 0000000..53d8e99
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/45080
+// { dg-options -std=c++0x }
+
+typedef void(*pfn)();
+
+template<typename=int>
+void f()
+{
+  pfn fn = []{};
+}
+
+void test()
+{
+  f();
+}