This is the mail archive of the gcc@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: Question about new warning system


Nathan Sidwell <nathan@codesourcery.com> wrote:

> I'm inclined to agree it is confusing. especially as in one place one has
to
> write warn_<foo> and in the other place one writes OPT_W<foo>.  It'd be
> nice if one just wrote
>     if (warn_foo && frobbed)
>       warning ("foo is frobbed");
>
> I don't care if it's spelt warn_foo, OPT_Wfoo, warning_p(foo) or whatever,
> so long as it's spelt only one way.  The 'warning (OPT_Wfoo, ...)' syntax
> helps only where there is no conditional before the warning -- how often
> does that occur?  The way it currently is, one runs the risk of writing
> if (warn_c_cast
>        && .....
>     && .....
>     && .....)
>   warning (OPT_Wconst_cast, ...)

Actually, the point is that you *never* need to explicitally name the
"warn_<foo>" variable unless you are optimizing. In other words, code which
presently is:

if (warn_foo
    && frobbed)
   warning (0, "foo is frobbed");

should be replaced with:

if (frobbed)
   warning (OPT_Wfoo, "foo is frobbed");

You need to pass the option to warning() also for another reason: we want to
be able to optionally print which flag can be used to disable each warning,
so warning() has to be smarter than it used to be.
-- 
Giovanni Bajo


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