diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-12-17 22:19:57 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-12-17 22:19:57 +0000 |
commit | 2342ef75797a2ad6c9d7a784cfff220fd1a66008 (patch) | |
tree | a8e7b9bd4b33de62c3b30ca34ac092e8d0fee56e /lib/Parse/ParseStmt.cpp | |
parent | 2fb78a70536274426302415b6fc54a1074788e91 (diff) |
Do proper recovery from an invalid switch condiition. Fixes PR3229.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 9f8771c919..d22fbb7044 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -611,9 +611,10 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement() { OwningExprResult Cond(Actions); if (ParseParenExprOrCondition(Cond)) return StmtError(); - - OwningStmtResult Switch(Actions, - Actions.ActOnStartOfSwitchStmt(Cond.release())); + + OwningStmtResult Switch(Actions); + if (!Cond.isInvalid()) + Switch = Actions.ActOnStartOfSwitchStmt(Cond.release()); // C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if // there is no compound stmt. C90 does not have this clause. We only do this |