Turn -fallow-unreachable-code into a -Wunreachable-code
authorWolfgang Bumiller <blub@speed.at>
Thu, 20 Dec 2012 15:29:32 +0000 (16:29 +0100)
committerWolfgang Bumiller <blub@speed.at>
Thu, 20 Dec 2012 15:29:32 +0000 (16:29 +0100)
ast.c
opts.c
opts.def

diff --git a/ast.c b/ast.c
index 5cb8651d6d5b1e9428c5e3824ee26ce631e277ce..cbcfb09d624ab227610a02f03eebfbb9a8a717db 100644 (file)
--- 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 f1aa937a8cb573d158a69fd45f258955e21b1d5b..cc647ba924440699cff3f6936d7c89d47b53515f 100644 (file)
--- 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) {
index e08b57627fcb4e0d130517416aab0a3d9319e576..5f74e1c1054dea335941c78b221389293f05d3ad 100644 (file)
--- 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