Commit e905ac8a by Mike Stump Committed by Mike Stump

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
parent 75ec21db
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> 2000-01-26 Jason Merrill <jason@casey.cygnus.com>
* pt.c (unify): Use fold, not maybe_fold_nontype_arg. * pt.c (unify): Use fold, not maybe_fold_nontype_arg.
......
...@@ -3935,6 +3935,17 @@ pushdecl (x) ...@@ -3935,6 +3935,17 @@ pushdecl (x)
set_identifier_type_value_with_scope (name, NULL_TREE, set_identifier_type_value_with_scope (name, NULL_TREE,
current_binding_level); 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 /* If this is an extern function declaration, see if we
have a global definition or declaration for the function. */ have a global definition or declaration for the function. */
if (oldlocal == NULL_TREE if (oldlocal == NULL_TREE
...@@ -3961,11 +3972,10 @@ pushdecl (x) ...@@ -3961,11 +3972,10 @@ pushdecl (x)
&& TREE_PUBLIC (x)) && TREE_PUBLIC (x))
TREE_PUBLIC (name) = 1; 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. */ /* Warn if shadowing an argument at the top level of the body. */
else if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x) if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
/* Inline decls shadow nothing. */
&& !DECL_FROM_INLINE (x)
&& TREE_CODE (oldlocal) == PARM_DECL && TREE_CODE (oldlocal) == PARM_DECL
/* Don't complain if it's from an enclosing function. */ /* Don't complain if it's from an enclosing function. */
&& DECL_CONTEXT (oldlocal) == current_function_decl && DECL_CONTEXT (oldlocal) == current_function_decl
...@@ -3982,16 +3992,11 @@ pushdecl (x) ...@@ -3982,16 +3992,11 @@ pushdecl (x)
if (b->parm_flag == 1) if (b->parm_flag == 1)
cp_error ("declaration of `%#D' shadows a parameter", name); 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. */ /* Maybe warn if shadowing something else. */
else if (warn_shadow && !DECL_EXTERNAL (x) if (warn_shadow && !DECL_EXTERNAL (x)
/* Inline decls shadow nothing. */
&& !DECL_FROM_INLINE (x)
/* No shadow warnings for internally generated vars. */ /* No shadow warnings for internally generated vars. */
&& ! DECL_ARTIFICIAL (x) && ! DECL_ARTIFICIAL (x)
/* No shadow warnings for vars made for inlining. */ /* No shadow warnings for vars made for inlining. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment