fixed: -frelaxed-switch check was in the wrong position

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-11-25 19:42:16 +01:00
parent 353b1f945f
commit b59401db1b

View file

@ -2107,15 +2107,6 @@ static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **ou
if (!operand) if (!operand)
return false; 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); switchnode = ast_switch_new(ctx, operand);
/* closing paren */ /* 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"); parseerror(parser, "expected expression for case");
return false; 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")) { else if (!strcmp(parser_tokval(parser), "default")) {
swcase.value = NULL; swcase.value = NULL;