This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/53066] Wshadow should not warn for shadowing an extern function


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]