]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
WebAssembly: Correct an `index' global shadowing error for pre-4.8 GCC
authorMaciej W. Rozycki <macro@mips.com>
Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)
committerMaciej W. Rozycki <macro@mips.com>
Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)
Remove `-Wshadow' compilation errors:

cc1: warnings being treated as errors
.../bfd/wasm-module.c: In function 'wasm_scan_name_function_section':
.../bfd/wasm-module.c:312: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
.../bfd/wasm-module.c: In function 'wasm_register_section':
.../bfd/wasm-module.c:494: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
.../bfd/wasm-module.c: In function 'wasm_compute_custom_section_file_position':
.../bfd/wasm-module.c:523: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here

and:

cc1: warnings being treated as errors
.../opcodes/wasm32-dis.c: In function 'print_insn_wasm32':
.../opcodes/wasm32-dis.c:272: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
make[4]: *** [wasm32-dis.lo] Error 1

which for versions of GCC before 4.8 prevent support for the WebAssembly
target from being built.  See also GCC PR c/53066.

bfd/
* wasm-module.c (wasm_scan_name_function_section): Rename
`index' local variable to `idx'.

opcodes/
* wasm32-dis.c (print_insn_wasm32): Rename `index' local
variable to `function_index'.

bfd/ChangeLog
bfd/wasm-module.c
opcodes/ChangeLog
opcodes/wasm32-dis.c

index 35fc174685cba482cccfa14d162ac91c18444b94..6b9e1d1d6500cde26a0a66d255a3a5634f1e66fa 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-13  Maciej W. Rozycki  <macro@mips.com>
+
+       * wasm-module.c (wasm_scan_name_function_section): Rename
+       `index' local variable to `idx'.
+
 2018-02-13  Alan Modra  <amodra@gmail.com>
 
        PR 22836
index 7525e630dfe05d6a33d3582d4051dcc664e370f0..2d5822deaaf8163deb01ddcb22dc55a7b0e2a2cb 100644 (file)
@@ -309,12 +309,12 @@ wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
 
   for (symcount = 0; p < end && symcount < tdata->symcount; symcount++)
     {
-      bfd_vma index;
+      bfd_vma idx;
       bfd_vma len;
       char *name;
       asymbol *sym;
 
-      READ_LEB128 (index, p, end);
+      READ_LEB128 (idx, p, end);
       READ_LEB128 (len, p, end);
 
       if (p + len < p || p + len > end)
@@ -330,7 +330,7 @@ wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
       sym = &symbols[symcount];
       sym->the_bfd = abfd;
       sym->name = name;
-      sym->value = index;
+      sym->value = idx;
       sym->flags = BSF_GLOBAL | BSF_FUNCTION;
       sym->section = space_function_index;
       sym->udata.p = NULL;
@@ -491,12 +491,12 @@ wasm_register_section (bfd *abfd ATTRIBUTE_UNUSED,
                       void *fsarg)
 {
   sec_ptr *numbered_sections = fsarg;
-  int index = wasm_section_name_to_code (asect->name);
+  int idx = wasm_section_name_to_code (asect->name);
 
-  if (index == 0)
+  if (idx == 0)
     return;
 
-  numbered_sections[index] = asect;
+  numbered_sections[idx] = asect;
 }
 
 struct compute_section_arg
@@ -520,14 +520,14 @@ wasm_compute_custom_section_file_position (bfd *abfd,
                                           void *fsarg)
 {
   struct compute_section_arg *fs = fsarg;
-  int index;
+  int idx;
 
   if (fs->failed)
     return;
 
-  index = wasm_section_name_to_code (asect->name);
+  idx = wasm_section_name_to_code (asect->name);
 
-  if (index != 0)
+  if (idx != 0)
     return;
 
   if (CONST_STRNEQ (asect->name, WASM_SECTION_PREFIX))
index c4f90392ef396fffeb2c7fe5dac99b477ae844f2..bfae54b110aa0baabbf3d7a320b055d08219fa14 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-13  Maciej W. Rozycki  <macro@mips.com>
+
+       * wasm32-dis.c (print_insn_wasm32): Rename `index' local
+       variable to `function_index'.
+
 2018-02-12  Henry Wong <henry@stuffedcow.net>
 
        * mips-opc.c (mips_builtin_opcodes): Correct "sigrie" encoding.
index dbb18973a6dc0261e8cdc33383bb96ecc9177464..d6f1697542493f53079c44aa684bbb2505a8c9d4 100644 (file)
@@ -269,7 +269,7 @@ print_insn_wasm32 (bfd_vma pc, struct disassemble_info *info)
   long flags = 0;
   long offset = 0;
   long depth = 0;
-  long index = 0;
+  long function_index = 0;
   long target_count = 0;
   long block_type = 0;
   int len = 1;
@@ -416,14 +416,14 @@ print_insn_wasm32 (bfd_vma pc, struct disassemble_info *info)
           break;
 
         case wasm_call:
-          index = wasm_read_leb128
+          function_index = wasm_read_leb128
             (pc + len, info, &error, &bytes_read, FALSE);
           if (error)
             return -1;
           len += bytes_read;
           prin (stream, " ");
           private_data->section_prefix = ".space.function_index";
-          (*info->print_address_func) ((bfd_vma) index, info);
+          (*info->print_address_func) ((bfd_vma) function_index, info);
           private_data->section_prefix = NULL;
           break;