]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
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)
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

index f086b5cf908c639d5ee396350a44f9fda9635c84..c4393182dd95bb4f085b6c4430793938ab4c8c40 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-19  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+       * h8300-tdep.c (h8300_is_argument_spill): Change how we check
+       whether disp is negative.
+
 2020-05-19  Simon Marchi  <simon.marchi@efficios.com>
 
        * symfile.h (struct symfile_segment_data)
index 3c2f502a124dec4d0d5c60209a6039aa6ea3f2a8..b569a23f2631cfb1f69d16e639734070b2b24cca 100644 (file)
@@ -178,10 +178,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
       if (IS_MOVB_Rn24_SP (read_memory_unsigned_integer (pc + 2,
                                                         2, byte_order)))
        {
-         LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
+         ULONGEST disp = read_memory_unsigned_integer (pc + 4, 4, byte_order);
 
          /* ... and d:24 is negative.  */
-         if (disp < 0 && disp > 0xffffff)
+         if ((disp & 0x00800000) != 0)
            return 8;
        }
     }
@@ -197,10 +197,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
       if (IS_MOVW_Rn24_SP (read_memory_unsigned_integer (pc + 2,
                                                         2, byte_order)))
        {
-         LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
+         ULONGEST disp = read_memory_unsigned_integer (pc + 4, 4, byte_order);
 
          /* ... and d:24 is negative.  */
-         if (disp < 0 && disp > 0xffffff)
+         if ((disp & 0x00800000) != 0)
            return 8;
        }
     }
@@ -219,10 +219,11 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
        {
          if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2, byte_order)))
            {
-             LONGEST disp = read_memory_integer (pc + 6, 4, byte_order);
+             ULONGEST disp = read_memory_unsigned_integer (pc + 6, 4,
+                                                           byte_order);
 
              /* ... and d:24 is negative.  */
-             if (disp < 0 && disp > 0xffffff)
+             if ((disp & 0x00800000) != 0)
                return 10;
            }
        }