diff options
author | John McCall <rjmccall@apple.com> | 2012-03-30 05:23:48 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-03-30 05:23:48 +0000 |
commit | 67cd5e094e431a0bed9e5d7dbf4e9c1e43a0039c (patch) | |
tree | 0e501182cbf5de4bd3a583f832a964473424f7b6 /clang/lib | |
parent | 678a53c3509c3734e0a822ab4b7d73e853b5c96a (diff) | |
download | bcm5719-llvm-67cd5e094e431a0bed9e5d7dbf4e9c1e43a0039c.tar.gz bcm5719-llvm-67cd5e094e431a0bed9e5d7dbf4e9c1e43a0039c.zip |
Forbid the block and lambda copy-capture of __autoreleasing variables
in ARC, under the usual reasoning limiting the use of __autoreleasing.
llvm-svn: 153725
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 6b30643db91..88ef8cd5d8e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -10087,6 +10087,17 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, return true; } + // Forbid the block-capture of autoreleasing variables. + if (CaptureType.getObjCLifetime() == Qualifiers::OCL_Autoreleasing) { + if (BuildAndDiagnose) { + Diag(Loc, diag::err_arc_autoreleasing_capture) + << /*block*/ 0; + Diag(Var->getLocation(), diag::note_previous_decl) + << Var->getDeclName(); + } + return true; + } + if (HasBlocksAttr || CaptureType->isReferenceType()) { // Block capture by reference does not change the capture or // declaration reference types. @@ -10179,6 +10190,16 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, if (!RefType->getPointeeType()->isFunctionType()) CaptureType = RefType->getPointeeType(); } + + // Forbid the lambda copy-capture of autoreleasing variables. + if (CaptureType.getObjCLifetime() == Qualifiers::OCL_Autoreleasing) { + if (BuildAndDiagnose) { + Diag(Loc, diag::err_arc_autoreleasing_capture) << /*lambda*/ 1; + Diag(Var->getLocation(), diag::note_previous_decl) + << Var->getDeclName(); + } + return true; + } } // Capture this variable in the lambda. |