mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	node.h: sign-extend
* node.h (nd_line): should sign-extend. shifting `VALUE` extends with zero bits if `sizeof(VALUE)` equals to `sizeof(int)`. the zero bits are truncated if `sizeof(VALUE)` is bigger enough. [ruby-core:80920] [Bug #13523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									eb486f24e1
								
							
						
					
					
						commit
						c6c55bb784
					
				
					 2 changed files with 11 additions and 1 deletions
				
			
		
							
								
								
									
										2
									
								
								node.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								node.h
									
										
									
									
									
								
							|  | @ -277,7 +277,7 @@ typedef struct RNode { | |||
| 
 | ||||
| #define NODE_LSHIFT (NODE_TYPESHIFT+7) | ||||
| #define NODE_LMASK  (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1) | ||||
| #define nd_line(n) (int)(RNODE(n)->flags>>NODE_LSHIFT) | ||||
| #define nd_line(n) (int)(((SIGNED_VALUE)RNODE(n)->flags)>>NODE_LSHIFT) | ||||
| #define nd_set_line(n,l) \ | ||||
|     RNODE(n)->flags=((RNODE(n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT)) | ||||
| 
 | ||||
|  |  | |||
|  | @ -978,6 +978,16 @@ x = __ENCODING__ | |||
|     assert_equal(line, obj.location.lineno, bug) | ||||
|   end | ||||
| 
 | ||||
|   def test_negative_line_number | ||||
|     bug = '[ruby-core:80920] [Bug #13523]' | ||||
|     obj = Object.new | ||||
|     obj.instance_eval("def t(e = false);raise if e; __LINE__;end", "test", -100) | ||||
|     assert_equal(-100, obj.t, bug) | ||||
|     assert_equal(-100, obj.method(:t).source_location[1], bug) | ||||
|     e = assert_raise(RuntimeError) {obj.t(true)} | ||||
|     assert_equal(-100, e.backtrace_locations.first.lineno, bug) | ||||
|   end | ||||
| 
 | ||||
| =begin | ||||
|   def test_past_scope_variable | ||||
|     assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 nobu
						nobu