From eb8dc60981c669a2b6c077e638a63656d5d02625 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 20 Dec 2012 16:29:32 +0100 Subject: [PATCH] Turn -fallow-unreachable-code into a -Wunreachable-code --- ast.c | 7 +++---- opts.c | 2 +- opts.def | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ast.c b/ast.c index 5cb8651..cbcfb09 100644 --- a/ast.c +++ b/ast.c @@ -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)) diff --git a/opts.c b/opts.c index f1aa937..cc647ba 100644 --- a/opts.c +++ b/opts.c @@ -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) { diff --git a/opts.def b/opts.def index e08b576..5f74e1c 100644 --- a/opts.def +++ b/opts.def @@ -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