[cfe-commits] r125799 - in /cfe/trunk: include/clang/Sema/ScopeInfo.h lib/Sema/SemaExpr.cpp

Chris Lattner sabre at nondot.org
Thu Feb 17 15:58:47 PST 2011


Author: lattner
Date: Thu Feb 17 17:58:47 2011
New Revision: 125799

URL: http://llvm.org/viewvc/llvm-project?rev=125799&view=rev
Log:
make block bodies handle undefined labels just like functions.

Modified:
    cfe/trunk/include/clang/Sema/ScopeInfo.h
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=125799&r1=125798&r2=125799&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Thu Feb 17 17:58:47 2011
@@ -64,7 +64,7 @@
   /// \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;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=125799&r1=125798&r2=125799&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Feb 17 17:58:47 2011
@@ -8800,7 +8800,7 @@
 /// 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 @@
   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);
 





More information about the cfe-commits mailing list