]> granicus.if.org Git - clang/commitdiff
Pop block scope after reading from it.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 12 Jul 2011 14:11:05 +0000 (14:11 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 12 Jul 2011 14:11:05 +0000 (14:11 +0000)
Found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134983 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index 1e04ac734e60a2159bd32fd4a3d9c4098f4e5d44..9f91052e4cb9fc3250955a5f42aede32ea045efb 100644 (file)
@@ -8496,10 +8496,6 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
 
   BSI->TheDecl->setBody(cast<CompoundStmt>(Body));
 
-  BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy);
-
-  const AnalysisBasedWarnings::Policy &WP = AnalysisWarnings.getDefaultPolicy();
-  PopFunctionOrBlockScope(&WP, Result->getBlockDecl(), Result);
   for (BlockDecl::capture_const_iterator ci = BSI->TheDecl->capture_begin(),
        ce = BSI->TheDecl->capture_end(); ci != ce; ++ci) {
     const VarDecl *variable = ci->getVariable();
@@ -8509,6 +8505,10 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
       getCurFunction()->setHasBranchProtectedScope();
   }
 
+  BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy);
+  const AnalysisBasedWarnings::Policy &WP = AnalysisWarnings.getDefaultPolicy();
+  PopFunctionOrBlockScope(&WP, Result->getBlockDecl(), Result);
+
   return Owned(Result);
 }