[PATCH] Fix -Wshadow warning in libiberty/cp-demangle.c
Mark Wielaard
mjw@redhat.com
Sat Sep 10 00:56:00 GMT 2016
valgrind contains a copy of the libiberty demangler which gets compiled
with -Wshadow. That shows the following warning:
cp-demangle.c: In function âd_substitutionâ:
cp-demangle.c:3772:35: warning: declaration of âcâ shadows a previous local
struct demangle_component *c;
^
cp-demangle.c:3708:8: note: shadowed declaration is here
char c;
^
Fix that by renaming the struct demangle_component variable to dc
and add -Wshadow to ac_libiberty_warn_cflags (the only warning is this one).
libiberty/ChangeLog:
* cp-demangle.c (d_substitution): Change struct demangle_component
variable name from c to dc.
* configure.ac (ac_libiberty_warn_cflags): Add -Wshadow.
* configure: Regenerate.
diff --git a/libiberty/configure b/libiberty/configure
index 0f8e9b9..91a051c 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -4398,7 +4398,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_libiberty_warn_cflags=
save_CFLAGS="$CFLAGS"
for real_option in -W -Wall -Wwrite-strings -Wc++-compat \
- -Wstrict-prototypes; do
+ -Wstrict-prototypes \
+ -Wshadow; do
# Do the check with the no- prefix removed since gcc silently
# accepts any -Wno-* option on purpose
case $real_option in
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 9d3f298..44bed8f 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -160,7 +160,8 @@ AC_SYS_LARGEFILE
AC_PROG_CPP_WERROR
ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wc++-compat \
- -Wstrict-prototypes], [ac_libiberty_warn_cflags])
+ -Wstrict-prototypes \
+ -Wshadow], [ac_libiberty_warn_cflags])
ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([], [ac_libiberty_warn_cflags])
AC_PROG_CC_C_O
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 1c2bce2..a843dc3 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -3769,7 +3769,7 @@ d_substitution (struct d_info *di, int prefix)
{
const char *s;
int len;
- struct demangle_component *c;
+ struct demangle_component *dc;
if (p->set_last_name != NULL)
di->last_name = d_make_sub (di, p->set_last_name,
@@ -3785,15 +3785,15 @@ d_substitution (struct d_info *di, int prefix)
len = p->simple_len;
}
di->expansion += len;
- c = d_make_sub (di, s, len);
+ dc = d_make_sub (di, s, len);
if (d_peek_char (di) == 'B')
{
/* If there are ABI tags on the abbreviation, it becomes
a substitution candidate. */
- c = d_abi_tags (di, c);
- d_add_substitution (di, c);
+ dc = d_abi_tags (di, dc);
+ d_add_substitution (di, dc);
}
- return c;
+ return dc;
}
}
--
1.8.3.1
More information about the Gcc-patches
mailing list