===================================================================
@@ -0,0 +1,12 @@
+// PR c++/51227
+// { dg-options "-std=c++0x" }
+
+template<int> int foo()
+{
+ [] (void i) { return 0; } (0); // { dg-error "incomplete|invalid|no match" }
+}
+
+void bar()
+{
+ foo<0>();
+}
===================================================================
@@ -9103,14 +9103,18 @@ instantiate_class_template_1 (tree type)
if (CLASSTYPE_LAMBDA_EXPR (type))
{
- tree lambda = CLASSTYPE_LAMBDA_EXPR (type);
- if (LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P (lambda))
+ tree decl = lambda_function (type);
+ if (decl)
{
- apply_lambda_return_type (lambda, void_type_node);
- LAMBDA_EXPR_RETURN_TYPE (lambda) = NULL_TREE;
+ tree lambda = CLASSTYPE_LAMBDA_EXPR (type);
+ if (LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P (lambda))
+ {
+ apply_lambda_return_type (lambda, void_type_node);
+ LAMBDA_EXPR_RETURN_TYPE (lambda) = NULL_TREE;
+ }
+ instantiate_decl (decl, false, false);
+ maybe_add_lambda_conv_op (type);
}
- instantiate_decl (lambda_function (type), false, false);
- maybe_add_lambda_conv_op (type);
}
/* Set the file and line number information to whatever is given for