From: Steve Naroff Date: Wed, 15 Apr 2009 14:38:36 +0000 (+0000) Subject: Fix [clang10 regression] [sema] invalid illegal jump diagnostic. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b25ddfb1559d5c340239c33d98c987386543a947;p=clang Fix [clang10 regression] [sema] invalid illegal jump diagnostic. caused by: [sema] jumps into Obj-C exception blocks should be disallowed. Sema::RecursiveCalcLabelScopes() and Sema::RecursiveCalcJumpScopes() need to pop the ScopeStack within the statement iteration loop (was outside the loop). Eli, please review (thanks). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69165 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7cc3029aae..6456ee8d9a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2935,11 +2935,11 @@ void Sema::RecursiveCalcLabelScopes(llvm::DenseMap& LabelScopeMap, Stmt* CurCompound = isa(*i) ? *i : ParentCompoundStmt; RecursiveCalcLabelScopes(LabelScopeMap, PopScopeMap, ScopeStack, *i, CurCompound); + while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt) { + ScopeStack.pop_back(); + } } - while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt) { - ScopeStack.pop_back(); - } } void Sema::RecursiveCalcJumpScopes(llvm::DenseMap& LabelScopeMap, @@ -2970,10 +2970,9 @@ void Sema::RecursiveCalcJumpScopes(llvm::DenseMap& LabelScopeMap, if (isa(*i)) continue; RecursiveCalcJumpScopes(LabelScopeMap, PopScopeMap, GotoScopeMap, ScopeStack, *i); - } - - while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt) { - ScopeStack.pop_back(); + while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt) { + ScopeStack.pop_back(); + } } } diff --git a/test/SemaObjC/scope-check-try-catch.m b/test/SemaObjC/scope-check-try-catch.m index b11eb040d3..d01dba0778 100644 --- a/test/SemaObjC/scope-check-try-catch.m +++ b/test/SemaObjC/scope-check-try-catch.m @@ -16,3 +16,11 @@ L2: ; L3: ; } } + +void f0(int a) { + if (a) goto L0; + @try {} @finally {} + L0: + return; +} +