aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stump <mrs@wrs.com>2000-01-27 23:15:38 +0000
committerMike Stump <mrs@gcc.gnu.org>2000-01-27 23:15:38 +0000
commite905ac8a1a7bfd88994095f0de82ac31cca99925 (patch)
tree519b7e55a0831f77bbd3341557c5b6f64dc14b86
parent75ec21db305f832534b2072c02a2a785c3cc0b4c (diff)
downloadgcc-e905ac8a1a7bfd88994095f0de82ac31cca99925.zip
gcc-e905ac8a1a7bfd88994095f0de82ac31cca99925.tar.gz
gcc-e905ac8a1a7bfd88994095f0de82ac31cca99925.tar.bz2
decl.c (pushdecl): Fix up shadow warnings with respect to implicit for scopes.
* decl.c (pushdecl): Fix up shadow warnings with respect to implicit for scopes. Fixes for3.C From-SVN: r31655
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c47
2 files changed, 31 insertions, 21 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c497e6f..fbe1565 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 27 13:54:12 2000 Mike Stump <mrs@wrs.com>
+
+ * decl.c (pushdecl): Fix up shadow warnings with respect to implicit
+ for scopes.
+
2000-01-26 Jason Merrill <jason@casey.cygnus.com>
* pt.c (unify): Use fold, not maybe_fold_nontype_arg.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 72de97c..1406d64 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3935,6 +3935,17 @@ pushdecl (x)
set_identifier_type_value_with_scope (name, NULL_TREE,
current_binding_level);
+ if (oldlocal)
+ {
+ tree d = oldlocal;
+ while (oldlocal && DECL_DEAD_FOR_LOCAL (oldlocal))
+ {
+ oldlocal = DECL_SHADOWED_FOR_VAR (oldlocal);
+ }
+ if (oldlocal == NULL_TREE)
+ oldlocal = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (d));
+ }
+
/* If this is an extern function declaration, see if we
have a global definition or declaration for the function. */
if (oldlocal == NULL_TREE
@@ -3961,15 +3972,14 @@ pushdecl (x)
&& TREE_PUBLIC (x))
TREE_PUBLIC (name) = 1;
- if (DECL_FROM_INLINE (x))
- /* Inline decls shadow nothing. */;
-
/* Warn if shadowing an argument at the top level of the body. */
- else if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
- && TREE_CODE (oldlocal) == PARM_DECL
- /* Don't complain if it's from an enclosing function. */
- && DECL_CONTEXT (oldlocal) == current_function_decl
- && TREE_CODE (x) != PARM_DECL)
+ if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
+ /* Inline decls shadow nothing. */
+ && !DECL_FROM_INLINE (x)
+ && TREE_CODE (oldlocal) == PARM_DECL
+ /* Don't complain if it's from an enclosing function. */
+ && DECL_CONTEXT (oldlocal) == current_function_decl
+ && TREE_CODE (x) != PARM_DECL)
{
/* Go to where the parms should be and see if we
find them there. */
@@ -3982,20 +3992,15 @@ pushdecl (x)
if (b->parm_flag == 1)
cp_error ("declaration of `%#D' shadows a parameter", name);
}
- else if (warn_shadow && oldlocal != NULL_TREE
- && current_binding_level->is_for_scope
- && !DECL_DEAD_FOR_LOCAL (oldlocal))
- {
- warning ("variable `%s' shadows local",
- IDENTIFIER_POINTER (name));
- cp_warning_at (" this is the shadowed declaration", oldlocal);
- }
+
/* Maybe warn if shadowing something else. */
- else if (warn_shadow && !DECL_EXTERNAL (x)
- /* No shadow warnings for internally generated vars. */
- && ! DECL_ARTIFICIAL (x)
- /* No shadow warnings for vars made for inlining. */
- && ! DECL_FROM_INLINE (x))
+ if (warn_shadow && !DECL_EXTERNAL (x)
+ /* Inline decls shadow nothing. */
+ && !DECL_FROM_INLINE (x)
+ /* No shadow warnings for internally generated vars. */
+ && ! DECL_ARTIFICIAL (x)
+ /* No shadow warnings for vars made for inlining. */
+ && ! DECL_FROM_INLINE (x))
{
if (oldlocal != NULL_TREE && TREE_CODE (oldlocal) == PARM_DECL)
warning ("declaration of `%s' shadows a parameter",