From 81cc4194dca1a128851fb0a5aed86e30df2542e3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 10 Jan 2013 15:23:04 +0100 Subject: [PATCH] fixed a bug which allowed some statements to end in tokens other than semicolons... (ie closing parens) --- parser.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/parser.c b/parser.c index b15280b..9912f56 100644 --- a/parser.c +++ b/parser.c @@ -1957,7 +1957,7 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma goto onerr; } if (parser->tok == ';' || - (!parens && parser->tok == ']')) + (!parens && (parser->tok == ']' || parser->tok == ')'))) { break; } @@ -1996,8 +1996,13 @@ static ast_expression* parse_expression(parser_t *parser, bool stopatcomma, bool ast_expression *e = parse_expression_leave(parser, stopatcomma, false, with_labels); if (!e) return NULL; + if (parser->tok != ';') { + parseerror(parser, "semicolon expected after expression"); + ast_unref(e); + return NULL; + } if (!parser_next(parser)) { - ast_delete(e); + ast_unref(e); return NULL; } return e; -- 2.39.2