* [PATCH] sim: Fix -Werror=shadow=local issue in m32c/gdb-if.c
@ 2024-01-21 22:57 Mark Wielaard
2024-01-22 3:43 ` Mike Frysinger
0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2024-01-21 22:57 UTC (permalink / raw)
To: gdb-patches; +Cc: Mark Wielaard
m32c/cpu.h defines mem as enum value, which causes GCC 14 to emit
sim/m32c/gdb-if.c: In function ‘sim_read’:
sim/m32c/gdb-if.c:162:33: error: declaration of ‘mem’ shadows a previous local [-Werror=shadow=local]
162 | sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length)
| ~~~~~~~~~^~~
In file included from ../../binutils-gdb/sim/m32c/gdb-if.c:38:
sim/m32c/cpu.h:83:3: note: shadowed declaration is here
83 | mem,
| ^~~
Fix this by renaming mem to memory in m32c/gdb-if.c
---
sim/m32c/gdb-if.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sim/m32c/gdb-if.c b/sim/m32c/gdb-if.c
index a1a96b450f3..ae268c5c045 100644
--- a/sim/m32c/gdb-if.c
+++ b/sim/m32c/gdb-if.c
@@ -159,24 +159,24 @@ sim_create_inferior (SIM_DESC sd, struct bfd * abfd,
}
uint64_t
-sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length)
+sim_read (SIM_DESC sd, uint64_t memory, void *buf, uint64_t length)
{
check_desc (sd);
- if (mem == 0)
+ if (memory == 0)
return 0;
- mem_get_blk ((int) mem, buf, length);
+ mem_get_blk ((int) memory, buf, length);
return length;
}
uint64_t
-sim_write (SIM_DESC sd, uint64_t mem, const void *buf, uint64_t length)
+sim_write (SIM_DESC sd, uint64_t memory, const void *buf, uint64_t length)
{
check_desc (sd);
- mem_put_blk ((int) mem, buf, length);
+ mem_put_blk ((int) memory, buf, length);
return length;
}
--
2.39.3
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] sim: Fix -Werror=shadow=local issue in m32c/gdb-if.c
2024-01-21 22:57 [PATCH] sim: Fix -Werror=shadow=local issue in m32c/gdb-if.c Mark Wielaard
@ 2024-01-22 3:43 ` Mike Frysinger
2024-01-22 11:27 ` Mark Wielaard
0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2024-01-22 3:43 UTC (permalink / raw)
To: Mark Wielaard; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 905 bytes --]
On 21 Jan 2024 23:57, Mark Wielaard wrote:
> m32c/cpu.h defines mem as enum value, which causes GCC 14 to emit
>
> sim/m32c/gdb-if.c: In function ‘sim_read’:
> sim/m32c/gdb-if.c:162:33: error: declaration of ‘mem’ shadows a previous local [-Werror=shadow=local]
> 162 | sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length)
> | ~~~~~~~~~^~~
> In file included from ../../binutils-gdb/sim/m32c/gdb-if.c:38:
> sim/m32c/cpu.h:83:3: note: shadowed declaration is here
> 83 | mem,
> | ^~~
>
> Fix this by renaming mem to memory in m32c/gdb-if.c
hmm, seems like we should change all sim_read/sim_write to use "addr"
instead of "mem" to be more consistent with other core APIs.
if you don't want to clean them all up, we should at least change the
include/sim/sim.h header and adjust m32c to match to fix the warnings.
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sim: Fix -Werror=shadow=local issue in m32c/gdb-if.c
2024-01-22 3:43 ` Mike Frysinger
@ 2024-01-22 11:27 ` Mark Wielaard
0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2024-01-22 11:27 UTC (permalink / raw)
To: Mike Frysinger; +Cc: gdb-patches
Hi Mike,
On Sun, 2024-01-21 at 22:43 -0500, Mike Frysinger wrote:
> On 21 Jan 2024 23:57, Mark Wielaard wrote:
> > m32c/cpu.h defines mem as enum value, which causes GCC 14 to emit
> >
> > sim/m32c/gdb-if.c: In function ‘sim_read’:
> > sim/m32c/gdb-if.c:162:33: error: declaration of ‘mem’ shadows a previous local [-Werror=shadow=local]
> > 162 | sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length)
> > | ~~~~~~~~~^~~
> > In file included from ../../binutils-gdb/sim/m32c/gdb-if.c:38:
> > sim/m32c/cpu.h:83:3: note: shadowed declaration is here
> > 83 | mem,
> > | ^~~
> >
> > Fix this by renaming mem to memory in m32c/gdb-if.c
>
> hmm, seems like we should change all sim_read/sim_write to use "addr"
> instead of "mem" to be more consistent with other core APIs.
OK, it looks like most already use addr, so I should be able to do
this. Just going to double check it doesn't introduce any other
shadowing issues with gcc 14.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-22 11:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21 22:57 [PATCH] sim: Fix -Werror=shadow=local issue in m32c/gdb-if.c Mark Wielaard
2024-01-22 3:43 ` Mike Frysinger
2024-01-22 11:27 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox