gdb: fix -Wtautological-overlap-compare error in h8300-tdep.c
authorYoshinori Sato <ysato@users.sourceforge.jp>
Tue, 19 May 2020 17:33:08 +0000 (13:33 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 19 May 2020 17:33:52 +0000 (13:33 -0400)
commit1d6ce4d31257e1ea49b3a1b257055bf8f7ff16af
treeb77c3f961e5f47b75e21337f9ccd0d05973912e0
parent6fd1d259e98354236fafd14ec05f3d6a377ede9f
gdb: fix -Wtautological-overlap-compare error in h8300-tdep.c

Compiling with clang 11 gives us:

      CXX    h8300-tdep.o
    /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:225:21: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare]
                  if (disp < 0 && disp > 0xffffff)
                      ~~~~~~~~~^~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:203:17: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare]
              if (disp < 0 && disp > 0xffffff)
                  ~~~~~~~~~^~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:184:17: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare]
              if (disp < 0 && disp > 0xffffff)
                  ~~~~~~~~~^~~~~~~~~~~~~~~~~~

Indeed, disp (of type LONGEST) can't be less than 0 and greater than
0xffffff.

Fix it by changing the way we check if disp is negative.  Check the sign
bit of disp, which is a 24-bit number.

gdb/ChangeLog:

* h8300-tdep.c (h8300_is_argument_spill): Change how we check
whether disp is negative.
gdb/ChangeLog
gdb/h8300-tdep.c