diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-11-25 06:20:02 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-11-25 06:20:02 +0000 |
| commit | 3ff3af4ff9b4ad40d5f945cbc68ac4c56393f8c8 (patch) | |
| tree | 8c48afbfd1ae9f048165d5293842f52c80c6ea0a /clang/lib/Sema/SemaStmt.cpp | |
| parent | 7baad7365a979a64456b180d66a754f7cf4ef22e (diff) | |
| download | bcm5719-llvm-3ff3af4ff9b4ad40d5f945cbc68ac4c56393f8c8.tar.gz bcm5719-llvm-3ff3af4ff9b4ad40d5f945cbc68ac4c56393f8c8.zip | |
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.
llvm-svn: 89847
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index b54de3e1711..e2b065bb905 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/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); |

