mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	add UNREACHABLE_RETURN
Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities.
This commit is contained in:
		
							parent
							
								
									c8dc2bf140
								
							
						
					
					
						commit
						de3e931df7
					
				
				
				Notes:
				
					git
				
				2020-06-29 11:06:32 +09:00 
				
			
			
			
		
		
					 14 changed files with 24 additions and 1 deletions
				
			
		
							
								
								
									
										1
									
								
								error.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								error.c
									
										
									
									
									
								
							|  | @ -930,6 +930,7 @@ rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type) | |||
|     const char *expected = data_type->wrap_struct_name; | ||||
|     rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected %s)", | ||||
|              actual, expected); | ||||
|     UNREACHABLE_RETURN(NULL); | ||||
| } | ||||
| 
 | ||||
| /* exception classes */ | ||||
|  |  | |||
							
								
								
									
										1
									
								
								file.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								file.c
									
										
									
									
									
								
							|  | @ -5433,6 +5433,7 @@ rb_f_test(int argc, VALUE *argv, VALUE _) | |||
|     else { | ||||
|         rb_raise(rb_eArgError, "unknown command \"\\x%02X\"", cmd); | ||||
|     } | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										2
									
								
								io.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								io.c
									
										
									
									
									
								
							|  | @ -4199,6 +4199,7 @@ rb_io_each_codepoint(VALUE io) | |||
| 
 | ||||
|   invalid: | ||||
|     rb_raise(rb_eArgError, "invalid byte sequence in %s", rb_enc_name(enc)); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -5578,6 +5579,7 @@ rb_io_modestr_fmode(const char *modestr) | |||
| 
 | ||||
|   error: | ||||
|     rb_raise(rb_eArgError, "invalid access mode %s", modestr); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| int | ||||
|  |  | |||
|  | @ -4013,6 +4013,7 @@ fix_pow_inverted(VALUE x, VALUE minusb) | |||
| { | ||||
|     if (x == INT2FIX(0)) { | ||||
|         rb_num_zerodiv(); | ||||
|         UNREACHABLE_RETURN(Qundef); | ||||
|     } | ||||
|     else { | ||||
|         VALUE y = rb_int_pow(x, minusb); | ||||
|  |  | |||
							
								
								
									
										7
									
								
								object.c
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								object.c
									
										
									
									
									
								
							|  | @ -2574,6 +2574,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) | |||
| 
 | ||||
|   wrong_name: | ||||
|     rb_name_err_raise(wrong_constant_name, mod, name); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -2752,6 +2753,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod) | |||
| 
 | ||||
|   wrong_name: | ||||
|     rb_name_err_raise(wrong_constant_name, mod, name); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -2904,6 +2906,7 @@ rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod) | |||
| 
 | ||||
|   wrong_name: | ||||
|     rb_name_err_raise(wrong_constant_name, mod, name); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -3607,8 +3610,10 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error) | |||
|     return d; | ||||
| 
 | ||||
|   bad: | ||||
|     if (raise) | ||||
|     if (raise) { | ||||
|         rb_invalid_str(q, "Float()"); | ||||
|         UNREACHABLE_RETURN(nan("")); | ||||
|     } | ||||
|     else { | ||||
|         if (error) *error = 1; | ||||
|         return 0.0; | ||||
|  |  | |||
							
								
								
									
										2
									
								
								proc.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								proc.c
									
										
									
									
									
								
							|  | @ -549,6 +549,7 @@ bind_local_variable_get(VALUE bindval, VALUE sym) | |||
|   undefined: | ||||
|     rb_name_err_raise("local variable `%1$s' is not defined for %2$s", | ||||
|                       bindval, sym); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -2021,6 +2022,7 @@ rb_obj_singleton_method(VALUE obj, VALUE vid) | |||
|   /* undef: */ | ||||
|     rb_name_err_raise("undefined singleton method `%1$s' for `%2$s'", | ||||
|                       obj, vid); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  |  | |||
|  | @ -1900,6 +1900,7 @@ check_exec_redirect_fd(VALUE v, int iskey) | |||
| 
 | ||||
|   wrong: | ||||
|     rb_raise(rb_eArgError, "wrong exec redirect"); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| static VALUE | ||||
|  |  | |||
							
								
								
									
										2
									
								
								range.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								range.c
									
										
									
									
									
								
							|  | @ -836,6 +836,7 @@ range_each_bignum_endless(VALUE beg) | |||
|     for (;; beg = rb_big_plus(beg, INT2FIX(1))) { | ||||
|         rb_yield(beg); | ||||
|     } | ||||
|     UNREACHABLE; | ||||
| } | ||||
| 
 | ||||
| RBIMPL_ATTR_NORETURN() | ||||
|  | @ -847,6 +848,7 @@ range_each_fixnum_endless(VALUE beg) | |||
|     } | ||||
| 
 | ||||
|     range_each_bignum_endless(LONG2NUM(RUBY_FIXNUM_MAX + 1)); | ||||
|     UNREACHABLE; | ||||
| } | ||||
| 
 | ||||
| static VALUE | ||||
|  |  | |||
							
								
								
									
										1
									
								
								signal.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								signal.c
									
										
									
									
									
								
							|  | @ -274,6 +274,7 @@ signm2signo(VALUE *sig_ptr, int negative, int exit, int *prefix_ptr) | |||
|     } | ||||
|     rb_raise(rb_eArgError, "unsupported signal `%.*s%"PRIsVALUE"'", | ||||
|              prefix, signame_prefix, vsig); | ||||
|     UNREACHABLE_RETURN(0); | ||||
| } | ||||
| 
 | ||||
| static const char* | ||||
|  |  | |||
							
								
								
									
										2
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								string.c
									
										
									
									
									
								
							|  | @ -3015,6 +3015,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, | |||
|   incompatible: | ||||
|     rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s", | ||||
|              rb_enc_name(str_enc), rb_enc_name(ptr_enc)); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| VALUE | ||||
|  | @ -9679,6 +9680,7 @@ rb_str_crypt(VALUE str, VALUE salt) | |||
| 
 | ||||
|   short_salt: | ||||
|     rb_raise(rb_eArgError, "salt too short (need >=2 bytes)"); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										1
									
								
								thread.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								thread.c
									
										
									
									
									
								
							|  | @ -5175,6 +5175,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE | |||
|     rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list " | ||||
|              "for %+"PRIsVALUE" in %+"PRIsVALUE, | ||||
|              sym, rb_thread_current()); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  |  | |||
							
								
								
									
										1
									
								
								time.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								time.c
									
										
									
									
									
								
							|  | @ -5434,6 +5434,7 @@ end_submicro: ; | |||
| 
 | ||||
|   invalid_format: | ||||
|     rb_raise(rb_eTypeError, "marshaled time format differ"); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| /* :nodoc: */ | ||||
|  |  | |||
|  | @ -277,6 +277,7 @@ rb_path_to_class(VALUE pathname) | |||
|   undefined_class: | ||||
|     rb_raise(rb_eArgError, "undefined class/module % "PRIsVALUE, | ||||
|              rb_str_subseq(pathname, 0, p-path)); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| VALUE | ||||
|  | @ -3347,6 +3348,7 @@ rb_mod_remove_cvar(VALUE mod, VALUE name) | |||
|   not_defined: | ||||
|     rb_name_err_raise("class variable %1$s not defined for %2$s", | ||||
|                       mod, name); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| VALUE | ||||
|  |  | |||
|  | @ -846,6 +846,7 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missin | |||
|     return result; | ||||
|   missing: | ||||
|     raise_method_missing(ec, argc, argv, obj, call_status | MISSING_MISSING); | ||||
|     UNREACHABLE_RETURN(Qundef); | ||||
| } | ||||
| 
 | ||||
| #ifndef MJIT_HEADER | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 卜部昌平
						卜部昌平