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 debug/66869] [6 regression] -Wunused-function no longer warns for static declarations without definition


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66869

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- gcc/c/c-decl.c.jj   2015-12-15 14:04:03.790772497 +0100
+++ gcc/c/c-decl.c      2015-12-15 14:04:27.838447800 +0100
@@ -10723,11 +10723,19 @@ c_write_global_declarations_1 (tree glob
       if (TREE_CODE (decl) == FUNCTION_DECL
          && DECL_INITIAL (decl) == 0
          && DECL_EXTERNAL (decl)
-         && !TREE_PUBLIC (decl)
-         && C_DECL_USED (decl))
+         && !TREE_PUBLIC (decl))
        {
-         pedwarn (input_location, 0, "%q+F used but never defined", decl);
-         TREE_NO_WARNING (decl) = 1;
+         if (C_DECL_USED (decl))
+           {
+             pedwarn (input_location, 0, "%q+F used but never defined", decl);
+             TREE_NO_WARNING (decl) = 1;
+           }
+         /* For -Wunused-function push the unused statics into cgraph,
+            so that check_global_declaration emits the warning.  */
+         else if (warn_unused_function
+                  && ! DECL_ARTIFICIAL (decl)
+                  && ! TREE_NO_WARNING (decl))
+           cgraph_node::get_create (decl);
        }

       wrapup_global_declaration_1 (decl);

seems to work (untested though) for C, but for C++ the question is where to add
something like that, should that be in wrapup_globals_for_namespace?

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