This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH][arm] build fix for gcc-6 -Werror=shift-negative-value
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Mon, 15 Jun 2015 12:48:10 +0100
- Subject: [PATCH][arm] build fix for gcc-6 -Werror=shift-negative-value
- Authentication-results: sourceware.org; auth=none
binutils does not compile here when building it for aarch64 or arm
targets with gcc trunk native compiler:
opcodes/arm-dis.c: In function 'print_insn_coprocessor':
opcodes/arm-dis.c:3331:20: error: left shift of negative value [-Werror=shift-negative-value]
imm |= (-1 << 7);
^
The fix assumes 2's complement signed int representation on the host.
Is this 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 1585a4f..8e92cc5 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -3326,9 +3326,9 @@ print_insn_coprocessor (bfd_vma pc,
imm = (given & 0xf) | ((given & 0xe0) >> 1);
- /* Is ``imm'' a negative number? */
+ /* Is ``imm'' a negative number? Then sign-extend it. */
if (imm & 0x40)
- imm |= (-1 << 7);
+ imm |= ~0x7f;
func (stream, "%d", imm);
}