aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Parse/ParseStmt.cpp7
-rw-r--r--test/Parser/recovery.c3
2 files changed, 7 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
diff --git a/test/Parser/recovery.c b/test/Parser/recovery.c
index 78addb90e4..ea59516041 100644
--- a/test/Parser/recovery.c
+++ b/test/Parser/recovery.c
@@ -65,3 +65,6 @@ int test6248081() {
[10] // expected-error {{expected expression}}
}
+struct forward;
+void x(struct forward* x) {switch(x->a) {}}
+