This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] Fix -Wunused-function (PR debug/66869)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Marek Polacek <polacek at redhat dot com>, Jason Merrill <jason at redhat dot com>, Jan Hubicka <hubicka at ucw dot cz>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 26 Jan 2016 17:18:13 +0100
- Subject: Re: [C PATCH] Fix -Wunused-function (PR debug/66869)
- Authentication-results: sourceware.org; auth=none
- References: <20160125203829 dot GP3017 at tucnak dot redhat dot com> <CAFiYyc12VJd=HcmH6YsnwVWinfzBnMzq-WyujU85eg05LCUReg at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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