diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-12-01 01:01:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-12-01 01:01:09 +0000 |
commit | c401755f4660d6b42ed74d53e580e4a5f8c2ee9f (patch) | |
tree | 802ee35bbc141ea3ac9138973374bf5be3e1e9e6 /clang/lib/Sema/SemaExpr.cpp | |
parent | 640a126d81e172d6c124120edc16039913ebf4cc (diff) | |
download | bcm5719-llvm-c401755f4660d6b42ed74d53e580e4a5f8c2ee9f.tar.gz bcm5719-llvm-c401755f4660d6b42ed74d53e580e4a5f8c2ee9f.zip |
Fix the determination of whether a capture refers to an enclosing
scope when dealing with nested blocks. Fixes <rdar://problem/12778708>.
llvm-svn: 169065
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f6defdaf9f9..5b4fb297419 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -10832,13 +10832,14 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, // actually requires the destructor. if (isa<ParmVarDecl>(Var)) FinalizeVarWithDestructor(Var, Record); - + // According to the blocks spec, the capture of a variable from // the stack requires a const copy constructor. This is not true // of the copy/move done to move a __block variable to the heap. - Expr *DeclRef = new (Context) DeclRefExpr(Var, false, + Expr *DeclRef = new (Context) DeclRefExpr(Var, Nested, DeclRefType.withConst(), VK_LValue, Loc); + ExprResult Result = PerformCopyInitialization( InitializedEntity::InitializeBlock(Var->getLocation(), @@ -10923,7 +10924,7 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, if (BuildAndDiagnose) { ExprResult Result = captureInLambda(*this, LSI, Var, CaptureType, DeclRefType, Loc, - I == N-1); + Nested); if (!Result.isInvalid()) CopyExpr = Result.take(); } |