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);