Fix rdar://6719156 - clang should emit a better error when blocks are disabled but are used anyway
by changing blocks from being disabled in the parser to being disabled
in Sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67816 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index c0b2877..913f9ba 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -776,10 +776,7 @@
     return ParseObjCAtExpression(AtLoc);
   }
   case tok::caret:
-    if (getLang().Blocks)
-      return ParsePostfixExpressionSuffix(ParseBlockLiteralExpression());
-    Diag(Tok, diag::err_expected_expression);
-    return ExprError();
+    return ParsePostfixExpressionSuffix(ParseBlockLiteralExpression());
   case tok::l_square:
     // These can be followed by postfix-expr pieces.
     if (getLang().ObjC1)
@@ -1344,18 +1341,17 @@
 
 
   OwningExprResult Result(Actions, true);
-  if (Tok.is(tok::l_brace)) {
-    OwningStmtResult Stmt(ParseCompoundStatementBody());
-    if (!Stmt.isInvalid()) {
-      Result = Actions.ActOnBlockStmtExpr(CaretLoc, move(Stmt), CurScope);
-    } else {
-      Actions.ActOnBlockError(CaretLoc, CurScope);
-    }
-  } else {
+  if (!Tok.is(tok::l_brace)) {
     // Saw something like: ^expr
     Diag(Tok, diag::err_expected_expression);
     return ExprError();
   }
+  
+  OwningStmtResult Stmt(ParseCompoundStatementBody());
+  if (!Stmt.isInvalid())
+    Result = Actions.ActOnBlockStmtExpr(CaretLoc, move(Stmt), CurScope);
+  else
+    Actions.ActOnBlockError(CaretLoc, CurScope);
   return move(Result);
 }