Along the error path for lambdas, mark the lambda class as invalid and finalize it

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150130 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp
index b90f5e3..033bf4a 100644
--- a/lib/Sema/SemaLambda.cpp
+++ b/lib/Sema/SemaLambda.cpp
@@ -265,6 +265,16 @@
 
   // Leave the context of the lambda.
   PopDeclContext();
+
+  // Finalize the lambda.
+  LambdaScopeInfo *LSI = getCurLambda();
+  CXXRecordDecl *Class = LSI->Lambda;
+  Class->setInvalidDecl();
+  SmallVector<Decl*, 4> Fields(Class->field_begin(), Class->field_end());
+  ActOnFields(0, Class->getLocation(), Class, Fields, 
+              SourceLocation(), SourceLocation(), 0);
+  CheckCompletedCXXClass(Class);
+
   PopFunctionScopeInfo();
 }