Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] sim: Fix cc -Werror=shadow=local in cr16/simops.c
@ 2024-01-21 22:52 Mark Wielaard
  2024-01-22  3:41 ` Mike Frysinger
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2024-01-21 22:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Mark Wielaard

include/opcode/cr16.h defines cc as an enum value, which causes GCC 14
to warn

sim/cr16/simops.c: In function ‘cond_stat’:
sim/cr16/simops.c:138:26: error: declaration of ‘cc’ shadows a previous local [-Werror=shadow=local]
  138 | static int cond_stat(int cc)
      |                      ~~~~^~
In file included from ../../binutils-gdb/sim/cr16/cr16-sim.h:26,
                 from ../../binutils-gdb/sim/cr16/simops.c:39:
sim/../include/opcode/cr16.h:149:3: note: shadowed declaration is here
  149 |   cc,
      |   ^~

Fix this by renaming cc in cr16/simops.c to cond.
---
 sim/cr16/simops.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sim/cr16/simops.c b/sim/cr16/simops.c
index b09284bf818..e56e5338dff 100644
--- a/sim/cr16/simops.c
+++ b/sim/cr16/simops.c
@@ -135,9 +135,9 @@ enum {
  * LT      Less Than                 Z and N flags are 0
  * GE      Greater Than or Equal To  Z or N flag is 1.  */
 
-static int cond_stat(int cc)
+static int cond_stat(int cond)
 {
-  switch (cc) 
+  switch (cond) 
     {
       case 0: return  PSR_Z; break;
       case 1: return !PSR_Z; break;
@@ -983,9 +983,9 @@ OP_14A_14 (SIM_DESC sd, SIM_CPU *cpu)
 void
 OP_1_4 (SIM_DESC sd, SIM_CPU *cpu)
 {
-  uint32_t tmp = 0, cc = cond_stat (OP[0]);
+  uint32_t tmp = 0, cond = cond_stat (OP[0]);
   trace_input ("b", OP_CONSTANT4, OP_DISPE9, OP_VOID);
-  if  (cc)
+  if  (cond)
     {
       if (sign_flag)
 	tmp =  (PC - (OP[1]));
@@ -1010,9 +1010,9 @@ OP_1_4 (SIM_DESC sd, SIM_CPU *cpu)
 void
 OP_18_8 (SIM_DESC sd, SIM_CPU *cpu)
 {
-  uint32_t tmp = 0, cc = cond_stat (OP[0]);
+  uint32_t tmp = 0, cond = cond_stat (OP[0]);
   trace_input ("b", OP_CONSTANT4, OP_DISP17, OP_VOID);
-  if (cc)
+  if (cond)
     {
       if (sign_flag)
 	tmp =  (PC - OP[1]);
@@ -1037,9 +1037,9 @@ OP_18_8 (SIM_DESC sd, SIM_CPU *cpu)
 void
 OP_10_10 (SIM_DESC sd, SIM_CPU *cpu)
 {
-  uint32_t tmp = 0, cc = cond_stat (OP[0]);
+  uint32_t tmp = 0, cond = cond_stat (OP[0]);
   trace_input ("b", OP_CONSTANT4, OP_DISP25, OP_VOID);
-  if (cc)
+  if (cond)
     {
       if (sign_flag)
 	tmp =  (PC - (OP[1]));
-- 
2.39.3


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

* Re: [PATCH] sim: Fix cc -Werror=shadow=local in cr16/simops.c
  2024-01-21 22:52 [PATCH] sim: Fix cc -Werror=shadow=local in cr16/simops.c Mark Wielaard
@ 2024-01-22  3:41 ` Mike Frysinger
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2024-01-22  3:41 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 16 bytes --]

lgtm, thx
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2024-01-22  3:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21 22:52 [PATCH] sim: Fix cc -Werror=shadow=local in cr16/simops.c Mark Wielaard
2024-01-22  3:41 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox