From b59401db1bfda25cace578544e999a9a9f0cb496 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sun, 25 Nov 2012 19:42:16 +0100 Subject: [PATCH] fixed: -frelaxed-switch check was in the wrong position --- parser.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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; -- 2.39.2