OSDN Git Service

* decl.c (pushdecl): Fix up shadow warnings with respect to implicit
authormrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Jan 2000 23:15:38 +0000 (23:15 +0000)
committermrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Jan 2000 23:15:38 +0000 (23:15 +0000)
for scopes.
Fixes for3.C

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31655 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c

index c497e6f..fbe1565 100644 (file)
@@ -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.
index 72de97c..1406d64 100644 (file)
@@ -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",