X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=parser.c;h=4432ed4472fe80d1a88d0b78d08c0086f31babab;hp=d374af7329a2a272ddc1cc3a0ce31e1a2fe305ee;hb=57c3d48711236e7438ac73609ae1d91560955798;hpb=debfe136a59968b250e7d57ac5d6f397c404bfb6 diff --git a/parser.c b/parser.c index d374af7..4432ed4 100644 --- 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");