ruby-changes:51812
From: nobu <ko1@a...>
Date: Tue, 24 Jul 2018 14:38:17 +0900 (JST)
Subject: [ruby-changes:51812] nobu:r64025 (trunk): UNREACHABLE_RETURN
nobu 2018-07-24 14:38:07 +0900 (Tue, 24 Jul 2018) New Revision: 64025 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64025 Log: UNREACHABLE_RETURN * include/ruby/ruby.h (UNREACHABLE_RETURN): UNREACHABLE at the end of non-void functions. Modified files: trunk/bignum.c trunk/dmydln.c trunk/enum.c trunk/eval.c trunk/ext/-test-/exception/enc_raise.c trunk/ext/-test-/iter/break.c trunk/ext/-test-/string/coderange.c trunk/ext/pty/pty.c trunk/ext/readline/readline.c trunk/ext/ripper/eventids2.c trunk/ext/socket/option.c trunk/ext/socket/raddrinfo.c trunk/ext/socket/socket.c trunk/include/ruby/ruby.h trunk/numeric.c trunk/pack.c trunk/proc.c trunk/process.c trunk/struct.c trunk/thread_sync.c trunk/variable.c trunk/vm_eval.c trunk/vm_method.c Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 64024) +++ include/ruby/ruby.h (revision 64025) @@ -44,6 +44,13 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L44 # define ASSUME(x) ((void)(x)) # endif #endif +#ifndef UNREACHABLE_RETURN +# ifdef UNREACHABLE +# define UNREACHABLE_RETURN(val) UNREACHABLE +# else +# define UNREACHABLE_RETURN(val) return (val) +# endif +#endif #ifndef UNREACHABLE # define UNREACHABLE ((void)0) /* unreachable */ #endif Index: thread_sync.c =================================================================== --- thread_sync.c (revision 64024) +++ thread_sync.c (revision 64025) @@ -1423,7 +1423,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L1423 undumpable(VALUE obj) { rb_raise(rb_eTypeError, "can't dump %"PRIsVALUE, rb_obj_class(obj)); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static VALUE Index: variable.c =================================================================== --- variable.c (revision 64024) +++ variable.c (revision 64025) @@ -1734,7 +1734,7 @@ rb_obj_remove_instance_variable(VALUE ob https://github.com/ruby/ruby/blob/trunk/variable.c#L1734 not_defined: rb_name_err_raise("instance variable %1$s not defined", obj, name); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } NORETURN(static void uninitialized_constant(VALUE, VALUE)); @@ -1805,7 +1805,7 @@ rb_mod_const_missing(VALUE klass, VALUE https://github.com/ruby/ruby/blob/trunk/variable.c#L1805 } uninitialized_constant(klass, name); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static void Index: enum.c =================================================================== --- enum.c (revision 64024) +++ enum.c (revision 64025) @@ -938,7 +938,7 @@ first_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, pa https://github.com/ruby/ruby/blob/trunk/enum.c#L938 MEMO_V1_SET(memo, i); rb_iter_break(); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static VALUE enum_take(VALUE obj, VALUE n); Index: pack.c =================================================================== --- pack.c (revision 64024) +++ pack.c (revision 64025) @@ -1936,7 +1936,7 @@ rb_uv_to_utf8(char buf[6], unsigned long https://github.com/ruby/ruby/blob/trunk/pack.c#L1936 } rb_raise(rb_eRangeError, "pack(U): value out of range"); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static const unsigned long utf8_limits[] = { Index: vm_eval.c =================================================================== --- vm_eval.c (revision 64024) +++ vm_eval.c (revision 64025) @@ -636,7 +636,7 @@ rb_method_missing(int argc, const VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L636 { rb_execution_context_t *ec = GET_EC(); raise_method_missing(ec, argc, argv, obj, ec->method_missing_reason); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } MJIT_FUNC_EXPORTED VALUE @@ -1851,7 +1851,7 @@ rb_f_throw(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1851 rb_scan_args(argc, argv, "11", &tag, &value); rb_throw_obj(tag, value); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } void Index: proc.c =================================================================== --- proc.c (revision 64024) +++ proc.c (revision 64025) @@ -2336,7 +2336,7 @@ rb_method_entry_min_max_arity(const rb_m https://github.com/ruby/ruby/blob/trunk/proc.c#L2336 return 0; } rb_bug("rb_method_entry_min_max_arity: invalid method entry type (%d)", def->type); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } int Index: vm_method.c =================================================================== --- vm_method.c (revision 64024) +++ vm_method.c (revision 64025) @@ -118,7 +118,7 @@ rb_f_notimplement(int argc, const VALUE https://github.com/ruby/ruby/blob/trunk/vm_method.c#L118 { rb_notimplement(); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static void Index: struct.c =================================================================== --- struct.c (revision 64024) +++ struct.c (revision 64025) @@ -217,7 +217,7 @@ rb_struct_getmember(VALUE obj, ID id) https://github.com/ruby/ruby/blob/trunk/struct.c#L217 } rb_name_err_raise("`%1$s' is not a struct member", obj, ID2SYM(id)); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static VALUE rb_struct_ref0(VALUE obj) {return RSTRUCT_GET(obj, 0);} Index: eval.c =================================================================== --- eval.c (revision 64024) +++ eval.c (revision 64025) @@ -728,7 +728,7 @@ rb_f_raise(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/eval.c#L728 } rb_raise_jump(rb_make_exception(argc, argv), *cause); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static VALUE Index: process.c =================================================================== --- process.c (revision 64024) +++ process.c (revision 64025) @@ -2896,7 +2896,7 @@ rb_f_exec(int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L2896 rb_exec_fail(eargp, err, errmsg); RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(err, fail_str); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } #define ERRMSG(str) do { if (errmsg && 0 < errmsg_buflen) strlcpy(errmsg, (str), errmsg_buflen); } while (0) @@ -4058,7 +4058,7 @@ rb_f_exit_bang(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/process.c#L4058 } _exit(istatus); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } void @@ -4129,7 +4129,7 @@ rb_f_exit(int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L4129 } rb_exit(istatus); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } @@ -4166,7 +4166,7 @@ rb_f_abort(int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L4166 rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit)); } - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } void @@ -5154,7 +5154,7 @@ rlimit_resource_type(VALUE rtype) https://github.com/ruby/ruby/blob/trunk/process.c#L5154 rb_raise(rb_eArgError, "invalid resource name: % "PRIsVALUE, rtype); - UNREACHABLE; + UNREACHABLE_RETURN(-1); } static rlim_t @@ -5195,7 +5195,7 @@ rlimit_resource_value(VALUE rval) https://github.com/ruby/ruby/blob/trunk/process.c#L5195 #endif rb_raise(rb_eArgError, "invalid resource value: %"PRIsVALUE, rval); - UNREACHABLE; + UNREACHABLE_RETURN((rlim_t)-1); } #endif @@ -7034,7 +7034,7 @@ p_uid_switch(VALUE obj) https://github.com/ruby/ruby/blob/trunk/process.c#L7034 rb_syserr_fail(EPERM, 0); } - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } #else static VALUE @@ -7147,7 +7147,7 @@ p_gid_switch(VALUE obj) https://github.com/ruby/ruby/blob/trunk/process.c#L7147 rb_syserr_fail(EPERM, 0); } - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } #else static VALUE Index: ext/-test-/exception/enc_raise.c =================================================================== --- ext/-test-/exception/enc_raise.c (revision 64024) +++ ext/-test-/exception/enc_raise.c (revision 64025) @@ -5,7 +5,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/-test-/exception/enc_raise.c#L5 enc_raise(VALUE exc, VALUE encoding, VALUE mesg) { rb_enc_raise(rb_to_encoding(encoding), exc, "%s", StringValueCStr(mesg)); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } void Index: ext/-test-/iter/break.c =================================================================== --- ext/-test-/iter/break.c (revision 64024) +++ ext/-test-/iter/break.c (revision 64025) @@ -5,7 +5,7 @@ iter_break(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/-test-/iter/break.c#L5 { rb_iter_break(); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static VALUE @@ -13,7 +13,7 @@ iter_break_value(VALUE self, VALUE val) https://github.com/ruby/ruby/blob/trunk/ext/-test-/iter/break.c#L13 { rb_iter_break_value(val); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } void Index: ext/-test-/string/coderange.c =================================================================== --- ext/-test-/string/coderange.c (revision 64024) +++ ext/-test-/string/coderange.c (revision 64025) @@ -17,7 +17,7 @@ coderange_int2sym(int coderange) https://github.com/ruby/ruby/blob/trunk/ext/-test-/string/coderange.c#L17 return sym_broken; } rb_bug("wrong condition of coderange"); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } /* return coderange without scan */ Index: ext/pty/pty.c =================================================================== --- ext/pty/pty.c (revision 64024) +++ ext/pty/pty.c (revision 64025) @@ -665,7 +665,7 @@ pty_check(int argc, VALUE *argv, VALUE s https://github.com/ruby/ruby/blob/trunk/ext/pty/pty.c#L665 if (!RTEST(exc)) return rb_last_status_get(); raise_from_check(cpid, status); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } static VALUE cPTY; Index: ext/readline/readline.c =================================================================== --- ext/readline/readline.c (revision 64024) +++ ext/readline/readline.c (revision 64025) @@ -1756,7 +1756,7 @@ rb_remove_history(int index) https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L1756 #else rb_notimplement(); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); #endif } Index: ext/socket/raddrinfo.c =================================================================== --- ext/socket/raddrinfo.c (revision 64024) +++ ext/socket/raddrinfo.c (revision 64025) @@ -2550,7 +2550,7 @@ rsock_io_socket_addrinfo(VALUE io, struc https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L2550 rb_raise(rb_eTypeError, "neither IO nor file descriptor"); } - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } /* Index: ext/socket/option.c =================================================================== --- ext/socket/option.c (revision 64024) +++ ext/socket/option.c (revision 64025) @@ -424,7 +424,7 @@ sockopt_ipv4_multicast_loop(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L424 } #endif rb_raise(rb_eTypeError, "ipv4_multicast_loop socket option expected"); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } #define inspect_ipv4_multicast_loop(a,b,c,d) \ @@ -475,7 +475,7 @@ sockopt_ipv4_multicast_ttl(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L475 } #endif rb_raise(rb_eTypeError, "ipv4_multicast_ttl socket option expected"); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } #define inspect_ipv4_multicast_ttl(a,b,c,d) \ Index: ext/socket/socket.c =================================================================== --- ext/socket/socket.c (revision 64024) +++ ext/socket/socket.c (revision 64025) @@ -1381,7 +1381,7 @@ sock_s_getnameinfo(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1381 errno = saved_errno; rsock_raise_socket_error("getnameinfo", error); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } /* Index: ext/ripper/eventids2.c =================================================================== --- ext/ripper/eventids2.c (revision 64024) +++ ext/ripper/eventids2.c (revision 64025) @@ -303,5 +303,5 @@ ripper_token2eventid(int tok) https://github.com/ruby/ruby/blob/trunk/ext/ripper/eventids2.c#L303 } rb_raise(rb_eRuntimeError, "[Ripper FATAL] unknown token %d", tok); - UNREACHABLE; + UNREACHABLE_RETURN(0); } Index: numeric.c =================================================================== --- numeric.c (revision 64024) +++ numeric.c (revision 64025) @@ -487,7 +487,7 @@ num_sadded(VALUE x, VALUE name) https://github.com/ruby/ruby/blob/trunk/numeric.c#L487 rb_id2str(mid), rb_obj_class(x)); - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } #if 0 Index: dmydln.c =================================================================== --- dmydln.c (revision 64024) +++ dmydln.c (revision 64025) @@ -6,5 +6,5 @@ dln_load(const char *file) https://github.com/ruby/ruby/blob/trunk/dmydln.c#L6 { rb_loaderror("this executable file can't load extension libraries"); - UNREACHABLE; + UNREACHABLE_RETURN(NULL); } Index: bignum.c =================================================================== --- bignum.c (revision 64024) +++ bignum.c (revision 64025) @@ -7097,7 +7097,7 @@ rb_int_powm(int const argc, VALUE * cons https://github.com/ruby/ruby/blob/trunk/bignum.c#L7097 return int_pow_tmp3(rb_int_modulo(a, m), b, m, nega_flg); } } - UNREACHABLE; + UNREACHABLE_RETURN(Qnil); } /* -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/