public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: fix -Wtautological-overlap-compare error in lm32-tdep.c
@ 2020-05-15 22:28 Simon Marchi
  2020-05-21 17:32 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Marchi @ 2020-05-15 22:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Building with clang 11, we get:

    /home/smarchi/src/binutils-gdb/gdb/lm32-tdep.c:84:44: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare]
        return ((regnum >= SIM_LM32_EA_REGNUM) && (regnum <= SIM_LM32_BA_REGNUM))
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Indeed, this doesn't make sense, as EA_REGNUM is greater than BA_REGNUM.
I'll assume that it was just a mistake and that these two should be
swapped.

The regnums for BA and EA are contiguous, so ultimately this particular
part of the condition is only true if regnum is == EA or == BA.  These
registers are Exception Address and Breakpoint Address, so I guess it
makes sense for them to be in the system register group.

The relevant reference is here:

  https://www.latticesemi.com/-/media/LatticeSemi/Documents/UserManuals/JL/LatticeMico32ProcessorReferenceManual39.ashx?document_id=52077

gdb/ChangeLog:

	* lm32-tdep.c (lm32_register_reggroup_p): Fix condition.
---
 gdb/lm32-tdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index 6b5bb1507ff3..73f8ae746f78 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -81,7 +81,7 @@ lm32_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
     return ((regnum >= SIM_LM32_R0_REGNUM) && (regnum <= SIM_LM32_RA_REGNUM))
       || (regnum == SIM_LM32_PC_REGNUM);
   else if (group == system_reggroup)
-    return ((regnum >= SIM_LM32_EA_REGNUM) && (regnum <= SIM_LM32_BA_REGNUM))
+    return ((regnum >= SIM_LM32_BA_REGNUM) && (regnum <= SIM_LM32_EA_REGNUM))
       || ((regnum >= SIM_LM32_EID_REGNUM) && (regnum <= SIM_LM32_IP_REGNUM));
   return default_register_reggroup_p (gdbarch, regnum, group);
 }
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdb: fix -Wtautological-overlap-compare error in lm32-tdep.c
  2020-05-15 22:28 [PATCH] gdb: fix -Wtautological-overlap-compare error in lm32-tdep.c Simon Marchi
@ 2020-05-21 17:32 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2020-05-21 17:32 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 2020-05-15 6:28 p.m., Simon Marchi via Gdb-patches wrote:
> Building with clang 11, we get:
> 
>     /home/smarchi/src/binutils-gdb/gdb/lm32-tdep.c:84:44: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare]
>         return ((regnum >= SIM_LM32_EA_REGNUM) && (regnum <= SIM_LM32_BA_REGNUM))
>                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Indeed, this doesn't make sense, as EA_REGNUM is greater than BA_REGNUM.
> I'll assume that it was just a mistake and that these two should be
> swapped.
> 
> The regnums for BA and EA are contiguous, so ultimately this particular
> part of the condition is only true if regnum is == EA or == BA.  These
> registers are Exception Address and Breakpoint Address, so I guess it
> makes sense for them to be in the system register group.
> 
> The relevant reference is here:
> 
>   https://www.latticesemi.com/-/media/LatticeSemi/Documents/UserManuals/JL/LatticeMico32ProcessorReferenceManual39.ashx?document_id=52077
> 
> gdb/ChangeLog:
> 
> 	* lm32-tdep.c (lm32_register_reggroup_p): Fix condition.
> ---
>  gdb/lm32-tdep.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
> index 6b5bb1507ff3..73f8ae746f78 100644
> --- a/gdb/lm32-tdep.c
> +++ b/gdb/lm32-tdep.c
> @@ -81,7 +81,7 @@ lm32_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
>      return ((regnum >= SIM_LM32_R0_REGNUM) && (regnum <= SIM_LM32_RA_REGNUM))
>        || (regnum == SIM_LM32_PC_REGNUM);
>    else if (group == system_reggroup)
> -    return ((regnum >= SIM_LM32_EA_REGNUM) && (regnum <= SIM_LM32_BA_REGNUM))
> +    return ((regnum >= SIM_LM32_BA_REGNUM) && (regnum <= SIM_LM32_EA_REGNUM))
>        || ((regnum >= SIM_LM32_EID_REGNUM) && (regnum <= SIM_LM32_IP_REGNUM));
>    return default_register_reggroup_p (gdbarch, regnum, group);
>  }
> -- 
> 2.26.2
> 

I pushed this patch.

Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-21 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 22:28 [PATCH] gdb: fix -Wtautological-overlap-compare error in lm32-tdep.c Simon Marchi
2020-05-21 17:32 ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).