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
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 34827c4..a24063f 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -4933,9 +4933,14 @@
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();