From 8cb63232d9c7c18a27e36edcd16ae42b2eccefee Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 28 May 2019 23:09:44 +0000 Subject: If capturing a variable fails, add a capture anyway (and mark it invalid) so that we can avoid repeated diagnostics for the same capture. llvm-svn: 361891 --- clang/lib/Sema/SemaLambda.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaLambda.cpp') diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index b2055dd650e..f6c9dee2a08 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -854,7 +854,7 @@ FieldDecl *Sema::buildInitCaptureField(LambdaScopeInfo *LSI, VarDecl *Var) { LSI->addCapture(Var, /*isBlock*/false, Var->getType()->isReferenceType(), /*isNested*/false, Var->getLocation(), SourceLocation(), - Var->getType(), Var->getInit()); + Var->getType(), Var->getInit(), /*Invalid*/false); return Field; } @@ -1586,6 +1586,9 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, for (unsigned I = 0, N = LSI->Captures.size(); I != N; ++I, ++CurField) { const Capture &From = LSI->Captures[I]; + if (From.isInvalid()) + return ExprError(); + assert(!From.isBlockCapture() && "Cannot capture __block variables"); bool IsImplicit = I >= LSI->NumExplicitCaptures; -- cgit v1.2.3