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/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 92a4de0..8922abd 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4589,6 +4589,10 @@
/// literal was successfully completed. ^(int x){...}
Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
StmtArg body, Scope *CurScope) {
+ // If blocks are disabled, emit an error.
+ if (!LangOpts.Blocks)
+ Diag(CaretLoc, diag::err_blocks_disable);
+
// Ensure that CurBlock is deleted.
llvm::OwningPtr<BlockSemaInfo> BSI(CurBlock);
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index f14eb65..dbe19e3 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -625,6 +625,10 @@
switch (DeclType.Kind) {
default: assert(0 && "Unknown decltype!");
case DeclaratorChunk::BlockPointer:
+ // If blocks are disabled, emit an error.
+ if (!LangOpts.Blocks)
+ Diag(DeclType.Loc, diag::err_blocks_disable);
+
if (DeclType.Cls.TypeQuals)
Diag(D.getIdentifierLoc(), diag::err_qualified_block_pointer_type);
if (!T.getTypePtr()->isFunctionType())