aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-25 06:20:02 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-25 06:20:02 +0000
commitbe724bab2ba7ad47aebced25e7c8ec551eb72d28 (patch)
treea6fdd9c24809e81d63ace183169b008fdac4839b /lib/Sema/SemaStmt.cpp
parentd78f598e020c12bf5a8fddc8d08a3be4cff8dc78 (diff)
When the condition of a switch() statement is semantically invalid,
still parse the body of the switch to try to avoid spurious diagnostics. Fixes PR5606. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89847 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index b54de3e171..e2b065bb90 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -288,12 +288,8 @@ Sema::ActOnStartOfSwitchStmt(FullExprArg cond, DeclPtrTy CondVar) {
if (CondResult.isInvalid())
return StmtError();
}
- Expr *ConditionExpr = CondResult.takeAs<Expr>();
- if (!ConditionExpr)
- return StmtError();
-
- CondResult.release();
- SwitchStmt *SS = new (Context) SwitchStmt(ConditionVar, ConditionExpr);
+ SwitchStmt *SS = new (Context) SwitchStmt(ConditionVar,
+ CondResult.takeAs<Expr>());
getSwitchStack().push_back(SS);
return Owned(SS);
}
@@ -496,6 +492,11 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
SS->setBody(BodyStmt, SwitchLoc);
getSwitchStack().pop_back();
+ if (SS->getCond() == 0) {
+ SS->Destroy(Context);
+ return StmtError();
+ }
+
Expr *CondExpr = SS->getCond();
QualType CondTypeBeforePromotion =
GetTypeBeforeIntegralPromotion(CondExpr);