From: Wolfgang (Blub) Bumiller Date: Sun, 25 Nov 2012 18:42:16 +0000 (+0100) Subject: fixed: -frelaxed-switch check was in the wrong position X-Git-Tag: 0.1.9~246 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=b59401db1bfda25cace578544e999a9a9f0cb496;p=xonotic%2Fgmqcc.git fixed: -frelaxed-switch check was in the wrong position --- diff --git a/parser.c b/parser.c index 3883631..370f92f 100644 --- a/parser.c +++ b/parser.c @@ -2107,15 +2107,6 @@ static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **ou if (!operand) return false; - if (!OPTS_FLAG(RELAXED_SWITCH)) { - opval = (ast_value*)operand; - if (!ast_istype(operand, ast_value) || !opval->constant) { - parseerror(parser, "case on non-constant values need to be explicitly enabled via -frelaxed-switch"); - ast_unref(operand); - return false; - } - } - switchnode = ast_switch_new(ctx, operand); /* closing paren */ @@ -2159,6 +2150,14 @@ static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **ou parseerror(parser, "expected expression for case"); return false; } + if (!OPTS_FLAG(RELAXED_SWITCH)) { + opval = (ast_value*)swcase.value; + if (!ast_istype(swcase.value, ast_value) || !opval->constant) { + parseerror(parser, "case on non-constant values need to be explicitly enabled via -frelaxed-switch"); + ast_unref(operand); + return false; + } + } } else if (!strcmp(parser_tokval(parser), "default")) { swcase.value = NULL;