]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
error when trying to break/continue outside of loops/switches instead of segfaulting...
authorWolfgang Bumiller <blub@speed.at>
Mon, 7 Jan 2013 14:19:53 +0000 (15:19 +0100)
committerWolfgang Bumiller <blub@speed.at>
Mon, 7 Jan 2013 14:19:53 +0000 (15:19 +0100)
parser.c

index d374af7329a2a272ddc1cc3a0ce31e1a2fe305ee..4432ed4472fe80d1a88d0b78d08c0086f31babab 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2644,6 +2644,13 @@ static bool parse_break_continue(parser_t *parser, ast_block *block, ast_express
         return false;
     }
 
+    if (!vec_size(loops)) {
+        if (is_continue)
+            parseerror(parser, "`continue` can only be used inside loops");
+        else
+            parseerror(parser, "`break` can only be used inside loops or switches");
+    }
+
     if (parser->tok == TOKEN_IDENT) {
         if (!OPTS_FLAG(LOOP_LABELS))
             parseerror(parser, "labeled loops not activated, try using -floop-labels");