]> granicus.if.org Git - clang/commitdiff
make block bodies handle undefined labels just like functions.
authorChris Lattner <sabre@nondot.org>
Thu, 17 Feb 2011 23:58:47 +0000 (23:58 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Feb 2011 23:58:47 +0000 (23:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125799 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/ScopeInfo.h
lib/Sema/SemaExpr.cpp

index c9d38715ec82645e7c155c05ededdc140b97c836..6a0d54d150dff73a9d63ef5307e31e78d2086fc9 100644 (file)
@@ -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<ReturnStmt *, 4> Returns;
+  llvm::SmallVector<ReturnStmt*, 4> Returns;
 
   void setHasBranchIntoScope() {
     HasBranchIntoScope = true;
index 6892424e099d65867787b5dd620339265dd73f06..6d339fd97cea9297179d99ffb61427b5803e6885 100644 (file)
@@ -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<CompoundStmt>(Body));
 
-  BSI->TheDecl->setBody(cast<CompoundStmt>(Body));
-
   // Check goto/label use.
-  if (BSI->checkLabelUse(0, *this)) {
-    PopFunctionOrBlockScope();
-    return ExprError();
-  }
+  BSI->checkLabelUse(Body, *this);
+  
+  BSI->TheDecl->setBody(cast<CompoundStmt>(Body));
 
   BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy);