aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@bitrange.com>2020-06-29 03:50:45 +0200
committerHans-Peter Nilsson <hp@bitrange.com>2020-06-29 03:50:45 +0200
commit9f27c36482d98a00d63fe76f7d740d5de4873ead (patch)
treebe7aa89b55ef2125380dd0bf283ecaee6747ae14 /binutils
parent07d22f648e56d7276fa7a4a73438005448c406fb (diff)
downloadgdb-9f27c36482d98a00d63fe76f7d740d5de4873ead.zip
gdb-9f27c36482d98a00d63fe76f7d740d5de4873ead.tar.gz
gdb-9f27c36482d98a00d63fe76f7d740d5de4873ead.tar.bz2
binutils/dwarf.c: Correct an `index' global shadowing error for pre-4.8 GCC
In older gcc, shadowing a function name with a local variable name is flagged as an error, certainly a bug but which is usually worked around in binutils: gcc -DHAVE_CONFIG_H -I. -I$SRC/binutils -I. -I$SRC/binutils -I../bfd -I$SRC/binutils/../bfd -I$SRC/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I$SRC/binutils/../zlib -g -O2 -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o $SRC/binutils/dwarf.c &&\ mv -f $depbase.Tpo $depbase.Po cc1: warnings being treated as errors $SRC/binutils/dwarf.c: In function 'display_debug_str_offsets': $SRC/binutils/dwarf.c:6913: error: declaration of 'index' shadows a global declaration /usr/include/string.h:309: error: shadowed declaration is here make[4]: *** [dwarf.o] Error 1 See also GCC PR c/53066. This is just another one that crept in since I and others last had to use an old version. The name "idx" was used in the preceding function, display_debug_addr. Also, it was declared c99 style (after a statement in the block). Committed as obvious. binutils: * dwarf.c (display_debug_str_offsets): Rename local variable index to idx. Move to top of function.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog5
-rw-r--r--binutils/dwarf.c9
2 files changed, 10 insertions, 4 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 657bc95..d5f9b21 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2020-06-29 Hans-Peter Nilsson <hp@bitrange.com>
+
+ * dwarf.c (display_debug_str_offsets): Rename local variable
+ index to idx. Move to top of function.
+
2020-06-29 Alan Modra <amodra@gmail.com>
* dwarf.c: Use C style comments.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 6e61bfd..34903bc 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -6848,6 +6848,8 @@ static int
display_debug_str_offsets (struct dwarf_section *section,
void *file ATTRIBUTE_UNUSED)
{
+ unsigned long idx;
+
if (section->size == 0)
{
printf (_("\nThe %s section is empty.\n"), section->name);
@@ -6910,8 +6912,7 @@ display_debug_str_offsets (struct dwarf_section *section,
printf (_(" Index Offset [String]\n"));
}
- unsigned long index;
- for (index = 0; length >= entry_length && curr < end; index ++)
+ for (idx = 0; length >= entry_length && curr < end; idx++)
{
dwarf_vma offset;
const unsigned char * string;
@@ -6919,11 +6920,11 @@ display_debug_str_offsets (struct dwarf_section *section,
SAFE_BYTE_GET_AND_INC (offset, curr, entry_length, end);
if (dwo)
string = (const unsigned char *)
- fetch_indexed_string (index, NULL, entry_length, dwo);
+ fetch_indexed_string (idx, NULL, entry_length, dwo);
else
string = fetch_indirect_string (offset);
- printf (" %8lu %8s %s\n", index, dwarf_vmatoa ("x", offset),
+ printf (" %8lu %8s %s\n", idx, dwarf_vmatoa ("x", offset),
string);
}
}