This is the mail archive of the gcc-help@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: Re[2]: Why "'X' used but never defined" is a warning and not error in gcc?


On Mon, 2012-10-08 at 17:30 +0200, Vincent Lefevre wrote:
> On 2012-10-08 12:43:09 +0200, Oleg Endo wrote:
> > Doesn't look so.  You can turn all warnings into errors by -Werror, but
> > there's no option to control this particular warning individually.
> 
> It is possible to turn *particular* warnings into errors, not just
> all warnings, with -Werror=<list_of_warnings>.

Yes, that is true.  But there is no way to turn off or turn into an
error the warning that is output in _this_particular_case_, because
there's no flag in GCC's code to do so.

gcc/toplev.c, function check_global_declaration_1, around line 470:

&& (warn_unused_function
    || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
  {
    if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
      pedwarn (input_location, 0, "%q+F used but never defined", decl);

This particular warning can be turned into an error by specifying
-pedantic-errors

Cheers,
Oleg


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