]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
Fix variable declarations in for-loop initializers
[xonotic/gmqcc.git] / parser.c
index 4a09583593a97c5cebe19090d9f5368e7ed89e7e..b629c8787a60911da9dc2db9baf9579535012a3d 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2588,16 +2588,17 @@ 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;
+        /* 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;
+        }
     }
 
     /* parse the condition */