]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.cpp
fix for loops
[xonotic/gmqcc.git] / parser.cpp
index 75f9312fc4bcd5ba61305e39889af8c46deb71d5..72f5479095c3b4a4ae3dacdf7a48fcdafbdc5b4e 100644 (file)
@@ -2480,18 +2480,20 @@ static bool parse_for_go(parser_t *parser, ast_block *block, ast_expression **ou
         initexpr = parse_expression_leave(parser, false, false, false);
         if (!initexpr)
             goto onerr;
-
         /* move on to condition */
         if (parser->tok != ';') {
             parseerror(parser, "expected semicolon after for-loop initializer");
             goto onerr;
         }
-
         if (!parser_next(parser)) {
             parseerror(parser, "expected for-loop condition");
             goto onerr;
         }
     }
+    else if (!parser_next(parser)) {
+        parseerror(parser, "expected for-loop condition");
+        goto onerr;
+    }
 
     /* parse the condition */
     if (parser->tok != ';') {
@@ -5685,6 +5687,8 @@ skipvar:
             ast_delete(basetype);
             for (auto &it : parser->gotos)
                 parseerror(parser, "undefined label: `%s`", it->name);
+            parser->gotos.clear();
+            parser->labels.clear();
             return true;
         } else {
             ast_expression *cexp;