]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
parse ahead into the return expression as expected
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Thu, 26 Jul 2012 21:26:34 +0000 (23:26 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Thu, 26 Jul 2012 21:26:34 +0000 (23:26 +0200)
parser.c

index 3ee206efaf713bbb123d0b0fef4b0aed62e781ce..f6444337889b5e5a6ae8972f98185e86a055a4fa 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -560,8 +560,15 @@ static bool parser_body_do(parser_t *parser, ast_block *block)
     {
         if (!strcmp(parser_tokval(parser), "return"))
         {
-            ast_expression *exp = parser_expression(parser);
+            ast_expression *exp;
             ast_return *ret;
+
+            if (!parser_next(parser)) {
+                parseerror(parser, "expected return expression");
+                return false;
+            }
+
+            exp = parser_expression(parser);
             if (!exp)
                 return false;
             ret = ast_return_new(exp->expression.node.context, exp);