Replace ABORTs followed by statement with ABORT_RET having dummy
authorIvan Maidanski <ivmai@mail.ru>
Mon, 23 Jan 2012 04:17:19 +0000 (08:17 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 23 Jan 2012 12:19:33 +0000 (16:19 +0400)
condition (to suppress 'statement unreachable' compiler warnings
caused by abort tagged as 'no-return')

* dbg_mlc.c (GC_debug_realloc): Replace ABORT() with ABORT_RET().
* gcj_mlc.c (mark_stack_limit): Likewise.
* os_dep.c (catch_exception_raise_state,
catch_exception_raise_state_identity): Likewise.
* typd_mlc.c (GC_descr_obj_size, GC_push_complex_descriptor): Likewise.
* include/private/gc_priv.h (ABORT_RET): New macro.
* mark.c (GC_mark_from): Put ABORT_RET instead of "cannot happen"
comment.

dbg_mlc.c
gcj_mlc.c
include/private/gc_priv.h
mark.c
os_dep.c
typd_mlc.c

index c6b76fe..f061236 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -869,7 +869,7 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
       default:
         result = NULL; /* initialized to prevent warning. */
         GC_err_printf("GC_debug_realloc: encountered bad kind\n");
-        ABORT("Bad kind");
+        ABORT_RET("Bad kind");
     }
 
     if (result != NULL) {
index a5f3fe5..5bbcbc6 100644 (file)
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -61,7 +61,7 @@ STATIC struct GC_ms_entry * GC_gcj_fake_mark_proc(word * addr GC_ATTR_UNUSED,
                         struct GC_ms_entry * mark_stack_limit GC_ATTR_UNUSED,
                         word env GC_ATTR_UNUSED)
 {
-    ABORT("No client gcj mark proc is specified");
+    ABORT_RET("No client gcj mark proc is specified");
     return mark_stack_ptr;
 }
 
index 7945f19..32f1eba 100644 (file)
@@ -447,6 +447,11 @@ typedef char * ptr_t;   /* A generic pointer to which we can add        */
 #   endif
 # endif
 
+/* Same as ABORT but does not have 'no-return' attribute.       */
+/* ABORT on dummy condition (which is always true).             */
+#define ABORT_RET(msg) { if ((signed_word)GC_current_warn_proc != -1) \
+                           ABORT(msg); }
+
 /* Exit abnormally, but without making a mess (e.g. out of memory) */
 # ifdef PCR
 #   define EXIT() PCR_Base_Exit(1,PCR_waitForever)
diff --git a/mark.c b/mark.c
index 4d70b59..1e58424 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -785,8 +785,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
           }
           goto retry;
         default:
-          /* Can't happen. */
           limit = 0; /* initialized to prevent warning. */
+          ABORT_RET("GC_mark_from: bad state");
       }
     } else /* Small object with length descriptor */ {
       mark_stack_top--;
index fbd9b81..27af6c9 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -3852,7 +3852,7 @@ catch_exception_raise_state(mach_port_name_t exception_port GC_ATTR_UNUSED,
     thread_state_t old_state GC_ATTR_UNUSED, int old_stateCnt GC_ATTR_UNUSED,
     thread_state_t new_state GC_ATTR_UNUSED, int new_stateCnt GC_ATTR_UNUSED)
 {
-  ABORT("Unexpected catch_exception_raise_state invocation");
+  ABORT_RET("Unexpected catch_exception_raise_state invocation");
   return(KERN_INVALID_ARGUMENT);
 }
 
@@ -3865,7 +3865,7 @@ catch_exception_raise_state_identity(
     thread_state_t old_state GC_ATTR_UNUSED, int old_stateCnt GC_ATTR_UNUSED,
     thread_state_t new_state GC_ATTR_UNUSED, int new_stateCnt GC_ATTR_UNUSED)
 {
-  ABORT("Unexpected catch_exception_raise_state_identity invocation");
+  ABORT_RET("Unexpected catch_exception_raise_state_identity invocation");
   return(KERN_INVALID_ARGUMENT);
 }
 
index 57fabdb..caba301 100644 (file)
@@ -431,8 +431,8 @@ STATIC word GC_descr_obj_size(complex_descriptor *d)
         return(GC_descr_obj_size(d -> sd.sd_first)
                + GC_descr_obj_size(d -> sd.sd_second));
       default:
-        ABORT("Bad complex descriptor");
-        /*NOTREACHED*/ return 0; /*NOTREACHED*/
+        ABORT_RET("Bad complex descriptor");
+        return 0;
     }
 }
 
@@ -488,8 +488,8 @@ STATIC mse * GC_push_complex_descriptor(word *addr, complex_descriptor *d,
           return(msp);
         }
       default:
-        ABORT("Bad complex descriptor");
-        /*NOTREACHED*/ return 0; /*NOTREACHED*/
+        ABORT_RET("Bad complex descriptor");
+        return 0;
    }
 }