diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-18 20:10:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-18 20:10:59 +0000 |
commit | bcfce66584e47bb07f49a86b7cb39b4fdd269a5a (patch) | |
tree | aecaa01150687b64751c2237453562d9140cf61b /lib/Sema/SemaStmt.cpp | |
parent | 4f2aac33fe0e181c1c96bc9b502343935a794b5e (diff) |
abstract the SwitchStack for blocks just like we do the goto labels.
This fixes a crash on invalid (test10). rdar://6805469
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69465 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index a5b188696a..6595b88122 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -112,7 +112,7 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprArg lhsval, rhsval = 0; } - if (SwitchStack.empty()) { + if (getSwitchStack().empty()) { Diag(CaseLoc, diag::err_case_not_in_switch); return StmtError(); } @@ -121,7 +121,7 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprArg lhsval, lhsval.release(); rhsval.release(); CaseStmt *CS = new (Context) CaseStmt(LHSVal, RHSVal, CaseLoc); - SwitchStack.back()->addSwitchCase(CS); + getSwitchStack().back()->addSwitchCase(CS); return Owned(CS); } @@ -137,13 +137,13 @@ Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, StmtArg subStmt, Scope *CurScope) { Stmt *SubStmt = static_cast<Stmt*>(subStmt.release()); - if (SwitchStack.empty()) { + if (getSwitchStack().empty()) { Diag(DefaultLoc, diag::err_default_not_in_switch); return Owned(SubStmt); } DefaultStmt *DS = new (Context) DefaultStmt(DefaultLoc, SubStmt); - SwitchStack.back()->addSwitchCase(DS); + getSwitchStack().back()->addSwitchCase(DS); return Owned(DS); } @@ -241,7 +241,7 @@ Sema::ActOnStartOfSwitchStmt(ExprArg cond) { } SwitchStmt *SS = new (Context) SwitchStmt(Cond); - SwitchStack.push_back(SS); + getSwitchStack().push_back(SS); return Owned(SS); } @@ -325,11 +325,11 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch, StmtArg Body) { Stmt *BodyStmt = (Stmt*)Body.release(); - SwitchStmt *SS = SwitchStack.back(); + SwitchStmt *SS = getSwitchStack().back(); assert(SS == (SwitchStmt*)Switch.get() && "switch stack missing push/pop!"); SS->setBody(BodyStmt, SwitchLoc); - SwitchStack.pop_back(); + getSwitchStack().pop_back(); Expr *CondExpr = SS->getCond(); QualType CondType = CondExpr->getType(); |