From e476bdce8cf3315c8ce852480503a8acc265bd54 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 17 Feb 2011 23:58:47 +0000 Subject: [PATCH] make block bodies handle undefined labels just like functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125799 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/ScopeInfo.h | 2 +- lib/Sema/SemaExpr.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h index c9d38715ec..6a0d54d150 100644 --- a/include/clang/Sema/ScopeInfo.h +++ b/include/clang/Sema/ScopeInfo.h @@ -64,7 +64,7 @@ public: /// \brief The list of return statements that occur within the function or /// block, if there is any chance of applying the named return value /// optimization. - llvm::SmallVector Returns; + llvm::SmallVector Returns; void setHasBranchIntoScope() { HasBranchIntoScope = true; diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 6892424e09..6d339fd97c 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -8800,7 +8800,7 @@ void Sema::ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) { /// ActOnBlockStmtExpr - This is called when the body of a block statement /// literal was successfully completed. ^(int x){...} ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, - Stmt *Body, Scope *CurScope) { + Stmt *Body, Scope *CurScope) { // If blocks are disabled, emit an error. if (!LangOpts.Blocks) Diag(CaretLoc, diag::err_blocks_disable); @@ -8866,13 +8866,10 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, if (getCurFunction()->NeedsScopeChecking() && !hasAnyErrorsInThisFunction()) DiagnoseInvalidJumps(cast(Body)); - BSI->TheDecl->setBody(cast(Body)); - // Check goto/label use. - if (BSI->checkLabelUse(0, *this)) { - PopFunctionOrBlockScope(); - return ExprError(); - } + BSI->checkLabelUse(Body, *this); + + BSI->TheDecl->setBody(cast(Body)); BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy);