This is the mail archive of the gcc-patches@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]

Re: [C PATCH] Fix -Wunused-function (PR debug/66869)


On Tue, Jan 26, 2016 at 04:21:08PM +0100, Richard Biener wrote:
> > --- gcc/c/c-decl.c.jj   2016-01-21 00:41:47.000000000 +0100
> > +++ gcc/c/c-decl.c      2016-01-25 16:36:31.973504082 +0100
> > @@ -10741,11 +10741,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);
> 
> Err, so why not warn here directly?

You mean check if it has a cgraph node (i.e. get instead of get_create) and
if it doesn't, warn?  What I'm worried in that case is that it might have a
cgraph node created later on for whatever reason and that we'll get double
warning (from here and from cgraphunit.c (check_global_declaration)).
I can try it though.

	Jakub


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