GNU Binutils with patches for OS216
Revisión | 9f27c36482d98a00d63fe76f7d740d5de4873ead (tree) |
---|---|
Tiempo | 2020-06-29 10:50:45 |
Autor | Hans-Peter Nilsson <hp@bitr...> |
Commiter | Hans-Peter Nilsson |
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.
@@ -1,3 +1,8 @@ | ||
1 | +2020-06-29 Hans-Peter Nilsson <hp@bitrange.com> | |
2 | + | |
3 | + * dwarf.c (display_debug_str_offsets): Rename local variable | |
4 | + index to idx. Move to top of function. | |
5 | + | |
1 | 6 | 2020-06-29 Alan Modra <amodra@gmail.com> |
2 | 7 | |
3 | 8 | * dwarf.c: Use C style comments. |
@@ -6848,6 +6848,8 @@ static int | ||
6848 | 6848 | display_debug_str_offsets (struct dwarf_section *section, |
6849 | 6849 | void *file ATTRIBUTE_UNUSED) |
6850 | 6850 | { |
6851 | + unsigned long idx; | |
6852 | + | |
6851 | 6853 | if (section->size == 0) |
6852 | 6854 | { |
6853 | 6855 | printf (_("\nThe %s section is empty.\n"), section->name); |
@@ -6910,8 +6912,7 @@ display_debug_str_offsets (struct dwarf_section *section, | ||
6910 | 6912 | printf (_(" Index Offset [String]\n")); |
6911 | 6913 | } |
6912 | 6914 | |
6913 | - unsigned long index; | |
6914 | - for (index = 0; length >= entry_length && curr < end; index ++) | |
6915 | + for (idx = 0; length >= entry_length && curr < end; idx++) | |
6915 | 6916 | { |
6916 | 6917 | dwarf_vma offset; |
6917 | 6918 | const unsigned char * string; |
@@ -6919,11 +6920,11 @@ display_debug_str_offsets (struct dwarf_section *section, | ||
6919 | 6920 | SAFE_BYTE_GET_AND_INC (offset, curr, entry_length, end); |
6920 | 6921 | if (dwo) |
6921 | 6922 | string = (const unsigned char *) |
6922 | - fetch_indexed_string (index, NULL, entry_length, dwo); | |
6923 | + fetch_indexed_string (idx, NULL, entry_length, dwo); | |
6923 | 6924 | else |
6924 | 6925 | string = fetch_indirect_string (offset); |
6925 | 6926 | |
6926 | - printf (" %8lu %8s %s\n", index, dwarf_vmatoa ("x", offset), | |
6927 | + printf (" %8lu %8s %s\n", idx, dwarf_vmatoa ("x", offset), | |
6927 | 6928 | string); |
6928 | 6929 | } |
6929 | 6930 | } |