From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail03.asahi-net.or.jp (mail03.asahi-net.or.jp [202.224.55.15]) by sourceware.org (Postfix) with ESMTP id 37E79385BF81 for ; Sun, 17 May 2020 13:54:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 37E79385BF81 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=users.sourceforge.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=ysato@users.sourceforge.jp Received: from sakura.ysato.name (ik1-413-38519.vs.sakura.ne.jp [153.127.30.23]) (Authenticated sender: PQ4Y-STU) by mail03.asahi-net.or.jp (Postfix) with ESMTPA id 4A692ED5B6; Sun, 17 May 2020 22:54:38 +0900 (JST) Received: from yo-satoh-debian.ysato.ml (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by sakura.ysato.name (Postfix) with ESMTPSA id 55D0B1C08E4; Sun, 17 May 2020 22:54:38 +0900 (JST) Date: Sun, 17 May 2020 22:54:34 +0900 Message-ID: <877dxaoeed.wl-ysato@users.sourceforge.jp> From: Yoshinori Sato To: Simon Marchi Cc: "gdb-patches@sourceware.org" Subject: Re: -Werror,-Wtautological-overlap-compare error in h8300-tdep.c In-Reply-To: <8704f67d-6950-7e26-ad91-69359bd328ee@polymtl.ca> References: <8704f67d-6950-7e26-ad91-69359bd328ee@polymtl.ca> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/26 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2020 13:54:42 -0000 On Sat, 16 May 2020 06:05:44 +0900, Simon Marchi wrote: > > When building with clang 11, we get: > > 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. > > The closest thing I could find to an instruction set reference was this: > > https://www.renesas.com/cn/en/doc/products/mpumcu/001/e602025_h8300.pdf > > ... but it didn't really help me decode this code. I'm reporting it in hope that > somebody that knows what they are doing would know how to fix it. > > Yoshinori, I CCed you because you happen to be the last person who did a meaningful commit > in h8300-tdep.c, so maybe you have an idea. > > Simon This instruction enhanced on h8300h. https://www.renesas.com/us/en/doc/products/mpumcu/001/rej09b0213_h8300h.pdf disp have 24bit value. So always 0 in upper byte. I think it's good to check like this. diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index 79c74001bc..d3d2bf84ab 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -178,10 +178,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADD R 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_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_ADD R 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_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,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADD R 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_integer (pc + 6, 4, byte_order); /* ... and d:24 is negative. */ - if (disp < 0 && disp > 0xffffff) + if ((disp & 0x00800000) != 0) return 10; } } -- Yosinori Sato