commit 3b93aba17af31a772141a871c3299250dbbda714
Author: Jason Merrill <jason@redhat.com>
Date: Wed May 25 01:21:49 2011 -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.
@@ -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
@@ -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);
new file mode 100644
@@ -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();
+}