From 5d430c1b34b6162d4cfbd472fae09e6ea282f3a3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 11 May 2020 00:24:14 +0900 Subject: Added more NORETURN declarations --- compile.c | 4 +++- cont.c | 4 +++- dir.c | 4 +++- encoding.c | 3 ++- enum.c | 1 + enumerator.c | 10 +++++++--- gc.c | 2 ++ hash.c | 3 ++- numeric.c | 2 ++ process.c | 14 +++++++++++--- thread_sync.c | 1 + 11 files changed, 37 insertions(+), 11 deletions(-) diff --git a/compile.c b/compile.c index 97548b422f..6f5569fd88 100644 --- a/compile.c +++ b/compile.c @@ -10856,11 +10856,13 @@ ibf_dump_object_unsupported(struct ibf_dump *dump, VALUE obj) rb_raise(rb_eNotImpError, "ibf_dump_object_unsupported: %s", buff); } +NORETURN(static VALUE ibf_load_object_unsupported(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)); + static VALUE ibf_load_object_unsupported(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset) { rb_raise(rb_eArgError, "unsupported"); - return Qnil; + UNREACHABLE_RETURN(Qnil); } static void diff --git a/cont.c b/cont.c index ac761ac0b9..38a1be12da 100644 --- a/cont.c +++ b/cont.c @@ -1610,6 +1610,8 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta } } +NORETURN(static VALUE rb_cont_call(int argc, VALUE *argv, VALUE contval)); + /* * call-seq: * cont.call(args, ...) @@ -1648,7 +1650,7 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval) cont->value = make_passing_arg(argc, argv); cont_restore_0(cont, &contval); - return Qnil; /* unreachable */ + UNREACHABLE_RETURN(Qnil); } /*********/ diff --git a/dir.c b/dir.c index 7860964075..5c12cd2185 100644 --- a/dir.c +++ b/dir.c @@ -1966,13 +1966,15 @@ rb_glob_warning(const char *path, VALUE a, const void *enc, int error) } #endif +NORETURN(static VALUE glob_func_error(VALUE val)); + static VALUE glob_func_error(VALUE val) { struct glob_error_args *arg = (struct glob_error_args *)val; VALUE path = rb_enc_str_new_cstr(arg->path, arg->enc); rb_syserr_fail_str(arg->error, path); - return Qnil; + UNREACHABLE_RETURN(Qnil); } static int diff --git a/encoding.c b/encoding.c index e20235f3d0..da2811ea6e 100644 --- a/encoding.c +++ b/encoding.c @@ -1302,12 +1302,13 @@ enc_compatible_p(VALUE klass, VALUE str1, VALUE str2) return rb_enc_from_encoding(enc); } +NORETURN(static VALUE enc_s_alloc(VALUE klass)); /* :nodoc: */ static VALUE enc_s_alloc(VALUE klass) { rb_undefined_alloc(klass); - return Qnil; + UNREACHABLE_RETURN(Qnil); } /* :nodoc: */ diff --git a/enum.c b/enum.c index 867eec8f81..89bbd5079d 100644 --- a/enum.c +++ b/enum.c @@ -1021,6 +1021,7 @@ enum_tally(VALUE obj) return enum_hashify(obj, 0, 0, tally_i); } +NORETURN(static VALUE first_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, params))); static VALUE first_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, params)) { diff --git a/enumerator.c b/enumerator.c index cc0cce8fae..c2fde9a9bc 100644 --- a/enumerator.c +++ b/enumerator.c @@ -2676,7 +2676,8 @@ lazy_with_index_proc(VALUE proc_entry, struct MEMO* result, VALUE memos, long me if (entry->proc) { rb_proc_call_with_block(entry->proc, 2, argv, Qnil); LAZY_MEMO_RESET_PACKED(result); - } else { + } + else { LAZY_MEMO_SET_VALUE(result, rb_ary_new_from_values(2, argv)); LAZY_MEMO_SET_PACKED(result); } @@ -2931,6 +2932,8 @@ producer_each_stop(VALUE dummy, VALUE exc) return rb_attr_get(exc, id_result); } +NORETURN(static VALUE producer_each_i(VALUE obj)); + static VALUE producer_each_i(VALUE obj) { @@ -2943,7 +2946,8 @@ producer_each_i(VALUE obj) if (init == Qundef) { curr = Qnil; - } else { + } + else { rb_yield(init); curr = init; } @@ -2953,7 +2957,7 @@ producer_each_i(VALUE obj) rb_yield(curr); } - return Qnil; + UNREACHABLE_RETURN(Qnil); } /* :nodoc: */ diff --git a/gc.c b/gc.c index ab75d6752a..b05b2969cd 100644 --- a/gc.c +++ b/gc.c @@ -968,6 +968,8 @@ void rb_gcdebug_print_obj_condition(VALUE obj); static VALUE define_final0(VALUE obj, VALUE block); +NORETURN(static void *gc_vraise(void *ptr)); +NORETURN(static void gc_raise(VALUE exc, const char *fmt, ...)); NORETURN(static void negative_size_allocation_error(const char *)); static void init_mark_stack(mark_stack_t *stack); diff --git a/hash.c b/hash.c index ab6dd3ba79..8b6ea34229 100644 --- a/hash.c +++ b/hash.c @@ -6328,6 +6328,7 @@ env_reject(VALUE _) return rb_hash_delete_if(env_to_hash()); } +NORETURN(static VALUE env_freeze(VALUE self)); /* * call-seq: * ENV.freeze @@ -6339,7 +6340,7 @@ static VALUE env_freeze(VALUE self) { rb_raise(rb_eTypeError, "cannot freeze ENV"); - return self; /* Not reached */ + UNREACHABLE_RETURN(self); } /* diff --git a/numeric.c b/numeric.c index e0729a284e..671b95cfc4 100644 --- a/numeric.c +++ b/numeric.c @@ -479,6 +479,8 @@ rb_num_coerce_relop(VALUE x, VALUE y, ID func) return c; } +NORETURN(static VALUE num_sadded(VALUE x, VALUE name)); + /* * :nodoc: * diff --git a/process.c b/process.c index 7ec3b54336..161b34dade 100644 --- a/process.c +++ b/process.c @@ -2931,6 +2931,8 @@ rb_f_exec(int argc, const VALUE *argv) UNREACHABLE_RETURN(Qnil); } +NORETURN(static VALUE f_exec(int c, const VALUE *a, VALUE _)); + /* * call-seq: * exec([env,] command... [,options]) @@ -3007,7 +3009,8 @@ rb_f_exec(int argc, const VALUE *argv) static VALUE f_exec(int c, const VALUE *a, VALUE _) { - return rb_f_exec(c, a); + rb_f_exec(c, a); + UNREACHABLE_RETURN(Qnil); } #define ERRMSG(str) do { if (errmsg && 0 < errmsg_buflen) strlcpy(errmsg, (str), errmsg_buflen); } while (0) @@ -4175,6 +4178,7 @@ exit_status_code(VALUE status) return istatus; } +NORETURN(static VALUE rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)); /* * call-seq: * Process.exit!(status=false) @@ -4231,6 +4235,7 @@ rb_f_exit(int argc, const VALUE *argv) UNREACHABLE_RETURN(Qnil); } +NORETURN(static VALUE f_exit(int c, const VALUE *a, VALUE _)); /* * call-seq: * exit(status=true) @@ -4275,7 +4280,8 @@ rb_f_exit(int argc, const VALUE *argv) static VALUE f_exit(int c, const VALUE *a, VALUE _) { - return rb_f_exit(c, a); + rb_f_exit(c, a); + UNREACHABLE_RETURN(Qnil); } /* @@ -4314,10 +4320,12 @@ rb_f_abort(int argc, const VALUE *argv) UNREACHABLE_RETURN(Qnil); } +NORETURN(static VALUE f_abort(int c, const VALUE *a, VALUE _)); static VALUE f_abort(int c, const VALUE *a, VALUE _) { - return rb_f_abort(c, a); + rb_f_abort(c, a); + UNREACHABLE_RETURN(Qnil); } void diff --git a/thread_sync.c b/thread_sync.c index 7af5172818..2e20812f4d 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -1437,6 +1437,7 @@ rb_condvar_broadcast(VALUE self) return self; } +NORETURN(static VALUE undumpable(VALUE obj)); /* :nodoc: */ static VALUE undumpable(VALUE obj) -- cgit v1.2.3