[PATCH gas/m68k] Fix a register range check

Gunther Nikl gnikl@justmail.de
Fri Mar 27 19:25:26 GMT 2020


Hello!

Building an older binutils version with clang 10 produced an unexpected
warning message: "overlapping comparisons always evaluate to true". And
indeed, a register range check erroneously used a "logical or" instead
of an "and". This bug is still present in master.

Checking the history of tc-m68k.c shows that this particular bug is really
an ancient one. It was introduced with the creation of the bison grammar
for operand parsing in 1995!


Regards,
Gunther Nikl

2020-03-27  Gunther Nikl  <gnikl@justmail.de>

       * config/tc-m68k.c (m68k_ip): Fix range check for index register
       with a suppressed address register.

-- cut --
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index 5483f8e017..fef91706c1 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -2794,7 +2797,7 @@ m68k_ip (char *instring)
 		      && opP->index.reg <= ZDATA7)
 		    nextword |= (opP->index.reg - ZDATA0) << 12;
 		  else if (opP->index.reg >= ZADDR0
-			   || opP->index.reg <= ZADDR7)
+			   && opP->index.reg <= ZADDR7)
 		    nextword |= (opP->index.reg - ZADDR0 + 8) << 12;
 		}
 
-- cut --



More information about the Binutils mailing list