aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-01 00:09:55 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-01 00:09:55 +0000
commitfe9b559f81535ade84d24c42569378f80df47847 (patch)
tree1e63c2da8092873ef64366ecd5100459ff4553e6 /lib/Sema/SemaExprCXX.cpp
parent48b68a0dc345b3208cbd9dda719b9b3ec167c8c2 (diff)
Diagnose attempts to explicitly capture a __block variable in a lambda.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r--lib/Sema/SemaExprCXX.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 34827c4e1c..a24063f860 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -4933,9 +4933,14 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
continue;
}
- // FIXME: This is completely wrong for nested captures and variables
- // with a non-trivial constructor.
- // FIXME: We should refuse to capture __block variables.
+ if (Var->hasAttr<BlocksAttr>()) {
+ Diag(C->Loc, diag::err_lambda_capture_block) << C->Id;
+ Diag(Var->getLocation(), diag::note_previous_decl) << C->Id;
+ continue;
+ }
+
+ // FIXME: If this is capture by copy, make sure that we can in fact copy
+ // the variable.
Captures.push_back(LambdaScopeInfo::Capture(Var, C->Kind == LCK_ByRef,
/*isNested*/false, 0));
CaptureMap[Var] = Captures.size();