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
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 9f8771c..d22fbb7 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -611,9 +611,10 @@
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