This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53066] Wshadow should not warn for shadowing an extern function
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 21 Apr 2012 16:41:42 +0000
- Subject: [Bug c/53066] Wshadow should not warn for shadowing an extern function
- Auto-submitted: auto-generated
- References: <bug-53066-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53066
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #1 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-04-21 16:41:42 UTC ---
Testing this patch:
--- gcc/c-decl.c (revision 186353)
+++ gcc/c-decl.c (working copy)
@@ -2570,12 +2570,19 @@ warn_if_shadowing (tree new_decl)
}
else if (TREE_CODE (old_decl) == PARM_DECL)
warning (OPT_Wshadow, "declaration of %q+D shadows a parameter",
new_decl);
else if (DECL_FILE_SCOPE_P (old_decl))
- warning (OPT_Wshadow, "declaration of %q+D shadows a global "
- "declaration", new_decl);
+ {
+ /* Do not warn for variables shadowing a function
+ declaration. */
+ if (TREE_CODE (old_decl) == FUNCTION_DECL)
+ break;
+ warning_at (DECL_SOURCE_LOCATION (new_decl), OPT_Wshadow,
+ "declaration of %qD shadows a global declaration",
+ new_decl);
+ }
else if (TREE_CODE (old_decl) == FUNCTION_DECL
&& DECL_BUILT_IN (old_decl))
{
warning (OPT_Wshadow, "declaration of %q+D shadows "
"a built-in function", new_decl);