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: Add a __nowarn__ keyword


On Fri, 10 Aug 2007, DJ Delorie wrote:

> Minor glitch...
> 
> The #pragma to enable the diagnostic also enables the warn_foo flag
> that goes with it, so if we have code like:
> 
> 	if (warn_foo)
> 	   warning (OPT_foo, "...");
> 
> then we need to make sure the warning function is called.  However,
> when we pop state, we don't restore all those warn_foo flags.  So,
> popping state may result in some warnings showing up as "warning:
> foo".
> 
> This happens because the default state in diagnostics.c is
> DK_UNSPECIFIED, not DK_IGNORED.  We do this so that the call itself
> tells us the default; calls to warning() generate warnings, etc.
> 
> Ideas?
> 
> The only thing I can think of is if we're turning the option on when
> it was off, we can go into the classification table and tweak that
> entry to DK_IGNORED, but that assumes that all warning() calls using
> that option pass the right OPT_*.

Eventually, when the pragma states are linked to ranges of source 
locations so that diagnostics issued after the front end can be correctly 
handled (mapped-location might help here), and all warning calls pass a 
suitable OPT_*, warn_foo should be on permanently once it's been turned on 
anywhere (so that blocks of code like the example you give conditional on 
warn_foo are executed whenever they might be useful), and it would be 
entirely for the diagnostic machinery to tell whether a warning such code 
issues is to be output at the given source location.  But I'm not sure 
what's best for now until we have the link to source location ranges and a 
full conversion to OPT_*.  (I suspect restoring the warn_foo variables 
when state is popped, but I don't know how hard that is.)

-- 
Joseph S. Myers
joseph@codesourcery.com


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