summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLambda.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-05-28 23:09:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-05-28 23:09:44 +0000
commit8cb63232d9c7c18a27e36edcd16ae42b2eccefee (patch)
tree95b8021376c56b45ab9a09111c2da0c033b0d31e /clang/lib/Sema/SemaLambda.cpp
parent94ef686f575c5cd66b0b30e34aaa5dc7b05ad361 (diff)
downloadbcm5719-llvm-8cb63232d9c7c18a27e36edcd16ae42b2eccefee.tar.gz
bcm5719-llvm-8cb63232d9c7c18a27e36edcd16ae42b2eccefee.zip
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
Diffstat (limited to 'clang/lib/Sema/SemaLambda.cpp')
-rw-r--r--clang/lib/Sema/SemaLambda.cpp5
1 files changed, 4 insertions, 1 deletions
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;
OpenPOWER on IntegriCloud