diff --git a/dmd/parse.c b/dmd/parse.c index f50b8799..17f1e8c4 100644 --- a/dmd/parse.c +++ b/dmd/parse.c @@ -3181,7 +3181,10 @@ Statement *Parser::parseStatement(int flags) } else elsebody = NULL; - s = new IfStatement(loc, arg, condition, ifbody, elsebody); + if (condition && ifbody) + s = new IfStatement(loc, arg, condition, ifbody, elsebody); + else + s = NULL; // don't propagate parsing errors break; } diff --git a/dmd/statement.c b/dmd/statement.c index 9cc4cba7..b88c4761 100644 --- a/dmd/statement.c +++ b/dmd/statement.c @@ -339,7 +339,8 @@ Statements *CompileStatement::flatten(Scope *sc) while (p.token.value != TOKeof) { Statement *s = p.parseStatement(PSsemi | PScurlyscope); - a->push(s); + if (s) // if no parsing errors + a->push(s); } return a; }