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


> [3] shows which options is used to enable/disable that diagnostic
> (assumming it is controled by a particular switch).  In either case
> the main diagnostic is always emitted.

No, [3] will also enable/disable the warning, as the OPT_* is used to
look up the variable, and the variable is checked.  If you do [1] you
end up checking the variable twice.

> As pointed out by JSM yesterday, it is not clear whether [1] should be
> preferred over [2] or the converse.  I think having two ways to
> control the same diagnostic is a bit confusing.  I think the
> difference between [1] and [2] is that warn_xxx can be true even
> though OPT_Wxxxx  is not explicitly specified -- e.g. it could be set
> as a consequence of setting another flag.  

No, if you use Var(warn_foo) in OPT_foo, then passing OPT_foo to
warning() will check if warn_foo is set - it does EXACTLY the same
logic as [1].  The only time [1] is appropriate is if there's
expensive logic between the warn_foo and the warning(), and even then
it's only an optimization.

As long as the variable is associated with the switch through Var(),
it doesn't matter how the variable is set.

[2] just doesn't work.  Ever.  Don't ever do [2].  It's wrong.


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