This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][arm] build fix for gcc-6 -Werror=shift-negative-value



On 15/06/15 13:03, Andreas Schwab wrote:
> Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> 
>> -		    /* Is ``imm'' a negative number?  */
>> +		    /* Is ``imm'' a negative number?  Then sign-extend it.  */
>>  		    if (imm & 0x40)
>> -		      imm |= (-1 << 7);
>> +		      imm |= ~0x7f;
> 
>                     imm = (imm ^ 0x40) - 0x40;
> 

hm right, then i don't need assumptions about signed int representation.

imm -= 0x80;

is even simpler, is that ok?

2015-06-15  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* opcodes/arm-dis.c (print_insn_coprocessor): Avoid negative shift.
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index e9f4425..818847d 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -3352,7 +3352,7 @@ print_insn_coprocessor (bfd_vma pc,
 
 		    /* Is ``imm'' a negative number?  */
 		    if (imm & 0x40)
-		      imm |= (-1 << 7);
+		      imm -= 0x80;
 
 		    func (stream, "%d", imm);
 		  }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]