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] gas: microblaze: fix shift overflow


This code tries to shift an integer 31 bits which triggers a werror:
gas/config/tc-microblaze.c:742:21: error: integer overflow in expression [-Werror=overflow]
  e->X_add_number |= -(1 << 31);

Cast the 1 to offsetT to match X_add_number to fix things.

2015-11-15  Mike Frysinger  <vapier@gentoo.org>

	* config/tc-microblaze.c (parse_imm): Add an offsetT cast.
---
 gas/config/tc-microblaze.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index ac7c828..0ec24f8 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -739,7 +739,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
     {
       /* Special case: sign extend negative 32-bit values to 64-bits.  */
       if ((e->X_add_number >> 31) == 1)
-	e->X_add_number |= -(1 << 31);
+	e->X_add_number |= -((offsetT) 1 << 31);
 
       if (e->X_add_number < min || e->X_add_number > max)
 	{
-- 
2.6.2


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