]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
Fix for loops
[xonotic/gmqcc.git] / parser.c
index 4a09583593a97c5cebe19090d9f5368e7ed89e7e..672ce86799044024dfc955d3dfc5aec31d5e4f28 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2013, 2014
+ * Copyright (C) 2012, 2013, 2014, 2015
  *     Wolfgang Bumiller
  *     Dale Weiler
  *
@@ -2588,16 +2588,22 @@ 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;
+        }
+    } else {
+        if (!parser_next(parser)) {
+            parseerror(parser, "expected for-loop condition");
+            goto onerr;
+        }
     }
 
     /* parse the condition */
@@ -2606,7 +2612,6 @@ static bool parse_for_go(parser_t *parser, ast_block *block, ast_expression **ou
         if (!cond)
             goto onerr;
     }
-
     /* move on to incrementor */
     if (parser->tok != ';') {
         parseerror(parser, "expected semicolon after for-loop initializer");