From: Wolfgang Bumiller Date: Mon, 7 Jan 2013 14:19:53 +0000 (+0100) Subject: error when trying to break/continue outside of loops/switches instead of segfaulting... X-Git-Tag: before-library~348 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=57c3d48711236e7438ac73609ae1d91560955798 error when trying to break/continue outside of loops/switches instead of segfaulting at codegen --- 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");