This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH][arm] build fix for gcc-6 -Werror=shift-negative-value
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Mon, 15 Jun 2015 14:14:09 +0100
- Subject: Re: [PATCH][arm] build fix for gcc-6 -Werror=shift-negative-value
- Authentication-results: sourceware.org; auth=none
- References: <557EBB7A dot 4060607 at arm dot com> <mvm381t9o1u dot fsf at hawking dot suse dot de>
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);
}