GMQCC_DEFINE_FLAG(OMIT_NULL_BYTES)
GMQCC_DEFINE_FLAG(ADJUST_VECTOR_FIELDS)
GMQCC_DEFINE_FLAG(FTEPP)
+ GMQCC_DEFINE_FLAG(RELAXED_SWITCH)
#endif
/* warning flags */
static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **out)
{
ast_expression *operand;
+ ast_value *opval;
ast_switch *switchnode;
ast_switch_case swcase;
if (!operand)
return false;
+ if (!OPTS_FLAG(RELAXED_SWITCH)) {
+ opval = (ast_value*)operand;
+ if (!ast_istype(operand, ast_value) || !opval->isconst) {
+ 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 */
varentry_t *ve;
ve = &vec_last(parser->locals);
- if (ast_istype(ve->var, ast_value) && !(((ast_value*)(ve->var))->uses)) {
- if (parsewarning(parser, WARN_UNUSED_VARIABLE, "unused variable: `%s`", ve->name))
- rv = false;
+ if (!parser->errors) {
+ if (ast_istype(ve->var, ast_value) && !(((ast_value*)(ve->var))->uses)) {
+ if (parsewarning(parser, WARN_UNUSED_VARIABLE, "unused variable: `%s`", ve->name))
+ rv = false;
+ }
}
mem_d(ve->name);
vec_pop(parser->locals);