error when trying to break/continue outside of loops/switches instead of segfaulting at codegen

This commit is contained in:
Wolfgang Bumiller 2013-01-07 15:19:53 +01:00
parent debfe136a5
commit 57c3d48711

View file

@ -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");