This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] S12Z/opcodes: Correct a `reg' global shadowing error for pre-4.8 GCC


Remove `-Wshadow' compilation errors:

cc1: warnings being treated as errors
.../opcodes/s12z-dis.c: In function 'lea_reg_xys_opr':
.../opcodes/s12z-dis.c:814: error: declaration of 'reg' shadows a global declaration
.../opcodes/s12z-dis.c:783: error: shadowed declaration is here
.../opcodes/s12z-dis.c: In function 'lea_reg_xys':
.../opcodes/s12z-dis.c:843: error: declaration of 'reg' shadows a global declaration
.../opcodes/s12z-dis.c:783: error: shadowed declaration is here
.../opcodes/s12z-dis.c: In function 'print_insn_loop_primitive':
.../opcodes/s12z-dis.c:2206: error: declaration of 'reg' shadows a global declaration
.../opcodes/s12z-dis.c:783: error: shadowed declaration is here

which for versions of GCC before 4.8 prevent support for S12Z targets 
from being built.  See also GCC PR c/53066.

	opcodes/
	* s12z-dis.c (lea_reg_xys_opr): Rename `reg' local variable to 
	`reg_xys'.
	(lea_reg_xys): Likewise.
	(print_insn_loop_primitive): Rename `reg' local variable to 
	`reg_dxy'.
---
Hi,

 I've noticed S12Z target support being added and I have now included it 
in my usual target list I use to regression-test submissions affecting 
generic parts of binutils.  This has resulted in the errors quoted, 
preventing the `s12z-elf' target from being built.

 Maybe it isn't worth to have such a new target supported with old build 
GCC, however it doesn't appear to me to hurt either.  This is the only 
build problem I have encountered and I have made a usable if not useful 
toolchain with this patch applied.

 This change follows earlier ones I made, such as commit 49d519ec2fe8 
("NDS32/GAS: Correct an `expr' global shadowing error for pre-4.8 GCC"), 
commit 87993319a56a ("WebAssembly: Correct an `index' global shadowing 
error for pre-4.8 GCC"), commit 89424b1d6965 ("RISC-V/GAS: Correct an 
`expr' global shadowing error for pre-4.8 GCC"), commit 731f7c4ea30c 
("ARC/GAS: Correct a `spaces' global shadowing error"), etc. so I hope it 
can be considered obviously correct.

 The only question might be the choice of the new names for the variables 
affected.  If any better ones could be used here, then I'll be happy to 
update the change.

 Otherwise OK to apply?

  Maciej
---
 opcodes/s12z-dis.c |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

binutils-s12z-reg-shadowed.diff
Index: binutils/opcodes/s12z-dis.c
===================================================================
--- binutils.orig/opcodes/s12z-dis.c	2018-05-23 17:03:54.000000000 +0100
+++ binutils/opcodes/s12z-dis.c	2018-07-05 12:31:14.425878303 +0100
@@ -811,22 +811,22 @@ lea_reg_xys_opr (bfd_vma memaddr, struct
   if (status < 0)
     return;
 
-  char *reg = NULL;
+  char *reg_xys = NULL;
   switch (byte & 0x03)
     {
     case 0x00:
-      reg = "x";
+      reg_xys = "x";
       break;
     case 0x01:
-      reg = "y";
+      reg_xys = "y";
       break;
     case 0x02:
-      reg = "s";
+      reg_xys = "s";
       break;
     }
 
   operand_separator (info);
-  (*info->fprintf_func) (info->stream, "%s", reg);
+  (*info->fprintf_func) (info->stream, "%s", reg_xys);
   opr_decode (memaddr, info);
 }
 
@@ -840,17 +840,17 @@ lea_reg_xys (bfd_vma memaddr, struct dis
   if (status < 0)
     return;
 
-  char *reg = NULL;
+  char *reg_xys = NULL;
   switch (byte & 0x03)
     {
     case 0x00:
-      reg = "x";
+      reg_xys = "x";
       break;
     case 0x01:
-      reg = "y";
+      reg_xys = "y";
       break;
     case 0x02:
-      reg = "s";
+      reg_xys = "s";
       break;
     }
 
@@ -861,7 +861,7 @@ lea_reg_xys (bfd_vma memaddr, struct dis
   int8_t v = byte;
 
   operand_separator (info);
-  (*info->fprintf_func) (info->stream, "%s, (%d,%s)", reg, v, reg);
+  (*info->fprintf_func) (info->stream, "%s, (%d,%s)", reg_xys, v, reg_xys);
 }
 
 
@@ -2203,7 +2203,7 @@ print_insn_loop_primitive (bfd_vma memad
   stpcpy (mnemonic + x, lb_condition [(lb & 0x70) >> 4]);
   x += 2;
 
-  const char *reg  = NULL;
+  const char *reg_dxy  = NULL;
   enum LP_MODE mode = -1;
   size_t i;
   for (i = 0; i < sizeof (lp_mode) / sizeof (lp_mode[0]); ++i)
@@ -2219,10 +2219,10 @@ print_insn_loop_primitive (bfd_vma memad
   switch (mode)
     {
     case LP_REG:
-      reg = registers [lb & 0x07].name;
+      reg_dxy = registers [lb & 0x07].name;
       break;
     case LP_XY:
-      reg = (lb & 0x1) ? "y" : "x";
+      reg_dxy = (lb & 0x1) ? "y" : "x";
       break;
     case LP_OPR:
       mnemonic[x++] = '.';
@@ -2240,7 +2240,7 @@ print_insn_loop_primitive (bfd_vma memad
   else
     {
       operand_separator (info);
-      (*info->fprintf_func) (info->stream, "%s", reg);
+      (*info->fprintf_func) (info->stream, "%s", reg_dxy);
     }
 
   rel_15_7 (memaddr + offs, info, offs + 1);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]