sim: Fix -Werror=shadow=local issue in m32c/gdb-if.c
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
Commit Message
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(-)
Comments
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
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
@@ -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;
}