From 418ad3ff107dfde7f6d7c3e87f810fbbb8515ed4 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 15 Dec 2014 07:46:12 +0000 Subject: Sema: Don't leave switch stack inconsistent when recovering We would exit Sema::ActOnFinishSwitchStmt early if we didn't have a body. This would leave an extra SwitchStmt on the SwitchStack. This fixes PR21841. llvm-svn: 224237 --- clang/lib/Sema/SemaStmt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaStmt.cpp') diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 8f6c5c6fe34..0c3bfd50acf 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -730,9 +730,10 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, assert(SS == getCurFunction()->SwitchStack.back() && "switch stack missing push/pop!"); + getCurFunction()->SwitchStack.pop_back(); + if (!BodyStmt) return StmtError(); SS->setBody(BodyStmt, SwitchLoc); - getCurFunction()->SwitchStack.pop_back(); Expr *CondExpr = SS->getCond(); if (!CondExpr) return StmtError(); -- cgit v1.2.3