mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-19 06:40:49 +00:00
error when trying to break/continue outside of loops/switches instead of segfaulting at codegen
This commit is contained in:
parent
debfe136a5
commit
57c3d48711
1 changed files with 7 additions and 0 deletions
7
parser.c
7
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");
|
||||
|
|
Loading…
Reference in a new issue