From: Douglas Gregor Date: Wed, 11 Mar 2009 23:54:15 +0000 (+0000) Subject: Properly restore ActiveScope when we exit parsing of a block. This X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a471aa85d9539421e5cff11a24dd01f000c760a;p=clang Properly restore ActiveScope when we exit parsing of a block. This should fix the largest problem in . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66741 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 58cd3909c2..2ce7499b25 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4591,11 +4591,18 @@ void Sema::ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) { // Ensure that CurBlock is deleted. llvm::OwningPtr CC(CurBlock); + // Before popping CurBlock, set ActiveScope to this scope's function + // or block parent. + ActiveScope = CurBlock->TheScope->getParent(); + while (ActiveScope && + ((ActiveScope->getFlags() & (Scope::FnScope | Scope::BlockScope)) == 0)) + ActiveScope = ActiveScope->getParent(); + // Pop off CurBlock, handle nested blocks. CurBlock = CurBlock->PrevBlockInfo; // FIXME: Delete the ParmVarDecl objects as well??? - + } /// ActOnBlockStmtExpr - This is called when the body of a block statement @@ -4608,8 +4615,12 @@ Sema::ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, StmtTy *body, PopDeclContext(); - // Before poping CurBlock, set ActiveScope to this scopes parent. + // Before popping CurBlock, set ActiveScope to this scope's function + // or block parent. ActiveScope = CurBlock->TheScope->getParent(); + while (ActiveScope && + ((ActiveScope->getFlags() & (Scope::FnScope | Scope::BlockScope)) == 0)) + ActiveScope = ActiveScope->getParent(); // Pop off CurBlock, handle nested blocks. CurBlock = CurBlock->PrevBlockInfo;