Diagnose attempts to explicitly capture a __block variable in a lambda.

llvm-svn: 149458
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 34827c4..a24063f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/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();