summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-04-15 14:38:36 +0000
committerSteve Naroff <snaroff@apple.com>2009-04-15 14:38:36 +0000
commitfab026204772deac21f4537046c7392b7274d3fa (patch)
tree695bf0dfd7f2941f0f8432d3337ae7ffd47b94c4
parent9428a21067027b9ee4512899c96630dfb26912b6 (diff)
downloadbcm5719-llvm-fab026204772deac21f4537046c7392b7274d3fa.tar.gz
bcm5719-llvm-fab026204772deac21f4537046c7392b7274d3fa.zip
Fix <rdar://problem/6791490> [clang10 regression] [sema] invalid illegal jump diagnostic.
caused by: <rdar://problem/6252084> [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). llvm-svn: 69165
-rw-r--r--clang/lib/Sema/SemaDecl.cpp13
-rw-r--r--clang/test/SemaObjC/scope-check-try-catch.m8
2 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7cc3029aae9..6456ee8d9a1 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2935,11 +2935,11 @@ void Sema::RecursiveCalcLabelScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
Stmt* CurCompound = isa<CompoundStmt>(*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<Stmt*, void*>& LabelScopeMap,
@@ -2970,10 +2970,9 @@ void Sema::RecursiveCalcJumpScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
if (isa<DeclStmt>(*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/clang/test/SemaObjC/scope-check-try-catch.m b/clang/test/SemaObjC/scope-check-try-catch.m
index b11eb040d38..d01dba0778a 100644
--- a/clang/test/SemaObjC/scope-check-try-catch.m
+++ b/clang/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;
+}
+
OpenPOWER on IntegriCloud