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
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 8f6c5c6..0c3bfd5 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -730,9 +730,10 @@
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();