public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: cris: disable -Wshadow=local in generated mloop files
@ 2023-12-23  4:31 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2023-12-23  4:31 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=87271996ea9a36a5235ea7ff0de6eb6be13cc869

commit 87271996ea9a36a5235ea7ff0de6eb6be13cc869
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Fri Dec 22 23:17:45 2023 -0500

    sim: cris: disable -Wshadow=local in generated mloop files
    
    The mloop files include CGEN generated switch files which have some
    nested assignments that expand into repeated shadowed variables.
    Fixing this looks fairly non-trivial as it appears to be interplay
    between the common CGEN code and how this particular set of cris
    insns are defined.  Disable the warning instead.
    
    In file included from sim/cris/mloop.in:286:
    sim/cris/semcrisv10f-switch.c: In function ‘crisv10f_engine_run_full’:
    sim/cris/semcrisv10f-switch.c:12383:8: error: declaration of ‘opval’ shadows a previous local [-Werror=shadow=local]
    12383 |     SI opval = tmp_addr;
          |        ^~~~~
    sim/cris/semcrisv10f-switch.c:12371:9: note: shadowed declaration is here
    12371 |     USI opval = ({   SI tmp_addr;
          |         ^~~~~
    
    And the code looks like:
            USI opval = ({
                    ...
                            {
                                    SI opval = tmp_addr;
                                    ...
                            }
                    ...
            });
    
    Since the CGEN code treats "opval" as an internal variable that the cpu
    definitions don't have direct access to, the likelihood of this being a
    real bug is low, so leave it be.  The warning is suppressed for more code
    that is hand written (e.g. the mloop logic), but disabling for the entire
    file is the easiest way to suppress while keeping it on everywhere else in
    the sim.

Diff:
---
 sim/Makefile.in   | 4 +++-
 sim/cris/local.mk | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sim/Makefile.in b/sim/Makefile.in
index 604732c698c..6b73533f9db 100644
--- a/sim/Makefile.in
+++ b/sim/Makefile.in
@@ -2160,7 +2160,9 @@ testsuite_common_CPPFLAGS = \
 
 @SIM_ENABLE_ARCH_cr16_TRUE@cr16_gencode_SOURCES = cr16/gencode.c
 @SIM_ENABLE_ARCH_cr16_TRUE@cr16_gencode_LDADD = cr16/cr16-opc.o
-@SIM_ENABLE_ARCH_cris_TRUE@AM_CFLAGS_cris_mloopv10f.o = -Wno-unused-but-set-variable
+@SIM_ENABLE_ARCH_cris_TRUE@AM_CFLAGS_cris_mloopv10f.o =  \
+@SIM_ENABLE_ARCH_cris_TRUE@	-Wno-unused-but-set-variable \
+@SIM_ENABLE_ARCH_cris_TRUE@	-Wno-shadow=local
 @SIM_ENABLE_ARCH_cris_TRUE@AM_CFLAGS_cris_mloopv32f.o = -Wno-unused-but-set-variable
 @SIM_ENABLE_ARCH_cris_TRUE@nodist_cris_libsim_a_SOURCES = \
 @SIM_ENABLE_ARCH_cris_TRUE@	cris/modules.c
diff --git a/sim/cris/local.mk b/sim/cris/local.mk
index 011f8029e49..a8eea65572a 100644
--- a/sim/cris/local.mk
+++ b/sim/cris/local.mk
@@ -19,6 +19,8 @@
 ## Some CGEN kludges are causing build-time warnings.  See cris.cpu for details.
 AM_CFLAGS_%C%_mloopv10f.o = -Wno-unused-but-set-variable
 AM_CFLAGS_%C%_mloopv32f.o = -Wno-unused-but-set-variable
+## Some CGEN assignments use variable names that are nested & repeated.
+AM_CFLAGS_%C%_mloopv10f.o += -Wno-shadow=local
 
 nodist_%C%_libsim_a_SOURCES = \
 	%D%/modules.c

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-23  4:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-23  4:31 [binutils-gdb] sim: cris: disable -Wshadow=local in generated mloop files Michael Frysinger

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).