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]

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


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);
 		  }

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