[gas/m68k] Fix a register range check

Message ID 20200327202526.0000445d@justmail.de
State New
Headers show
Series
  • [gas/m68k] Fix a register range check
Related show

Commit Message

Gunther Nikl March 27, 2020, 7:25 p.m.
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 --
-- cut --

Comments

Jose E. Marchesi via Binutils March 31, 2020, 7:31 a.m. | #1
On Fri, Mar 27, 2020 at 08:25:26PM +0100, Gunther Nikl wrote:
>        * config/tc-m68k.c (m68k_ip): Fix range check for index register

>        with a suppressed address register.


OK.

-- 
Alan Modra
Australia Development Lab, IBM
Gunther Nikl March 31, 2020, 7:47 p.m. | #2
On Tue, 31 Mar, 2020 18:01:52 +1030, Alan Modra wrote:
>

> On Fri, Mar 27, 2020 at 08:25:26PM +0100, Gunther Nikl wrote:

> >        * config/tc-m68k.c (m68k_ip): Fix range check for index

> > register with a suppressed address register.

> 

> OK.


Please commit, I don't have write access.

Regards,
Gunther Nikl
Jose E. Marchesi via Binutils April 2, 2020, 7:59 a.m. | #3
Hi Gunther,

>> OK.

> Please commit, I don't have write access.


Done.

Cheers
  Nick

Patch

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