Turn -fallow-unreachable-code into a -Wunreachable-code

This commit is contained in:
Wolfgang Bumiller 2012-12-20 16:29:32 +01:00
parent 145c011247
commit eb8dc60981
3 changed files with 5 additions and 6 deletions

7
ast.c
View file

@ -1570,10 +1570,9 @@ bool ast_block_codegen(ast_block *self, ast_function *func, bool lvalue, ir_valu
{
ast_expression_codegen *gen;
if (func->curblock->final && !ast_istype(self->exprs[i], ast_label)) {
if (OPTS_FLAG(ALLOW_UNREACHABLE_CODE))
continue;
compile_error(ast_ctx(self->exprs[i]), "unreachable statement");
return false;
if (compile_warning(ast_ctx(self->exprs[i]), WARN_UNREACHABLE_CODE, "unreachable statement"))
return false;
continue;
}
gen = self->exprs[i]->expression.codegen;
if (!(*gen)(self->exprs[i], func, false, out))

2
opts.c
View file

@ -50,11 +50,11 @@ static void opts_setdefault() {
opts_set(opts.warn, WARN_CONST_VAR, true);
opts_set(opts.warn, WARN_MULTIBYTE_CHARACTER, true);
opts_set(opts.warn, WARN_UNKNOWN_PRAGMAS, true);
opts_set(opts.warn, WARN_UNREACHABLE_CODE, true);
/* flags */
opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
opts_set(opts.flags, FTEPP, false);
opts_set(opts.flags, CORRECT_TERNARY, true);
opts_set(opts.flags, ALLOW_UNREACHABLE_CODE, true);
}
void opts_init(const char *output, int standard, size_t arraysize) {

View file

@ -40,7 +40,6 @@
GMQCC_DEFINE_FLAG(LNO)
GMQCC_DEFINE_FLAG(CORRECT_TERNARY)
GMQCC_DEFINE_FLAG(SINGLE_VECTOR_DEFS)
GMQCC_DEFINE_FLAG(ALLOW_UNREACHABLE_CODE)
#endif
/* warning flags */
@ -69,6 +68,7 @@
GMQCC_DEFINE_FLAG(MULTIBYTE_CHARACTER)
GMQCC_DEFINE_FLAG(TERNARY_PRECEDENCE)
GMQCC_DEFINE_FLAG(UNKNOWN_PRAGMAS)
GMQCC_DEFINE_FLAG(UNREACHABLE_CODE)
#endif
#ifdef GMQCC_TYPE_OPTIMIZATIONS