named warnings & individual warning control
Matt Austern
austern@apple.com
Fri Jun 25 21:04:00 GMT 2004
On Jun 25, 2004, at 12:48 PM, David Taylor wrote:
>> Date: Fri, 25 Jun 2004 14:25:07 -0400
>> From: DJ Delorie <dj@redhat.com>
>>
>>>> Also, -O[23] tends to confuse this as they defer the use of warning
>>>> flags until after the whole file is parsed, so pragmas between
>>>> function definitions don't do what you expect :-(
>>>
>>> I'm not sure what to say about the problem in the last paragraph;
>>> that's
>>> clearly a serious user interface issue. This is part of why I have
>>> long
>>> argued that only front ends should be permitted to issue warnings,
>>> and
>>> that all attempts to use back-end data flow analysis to issue
>>> warnings
>>> are mistaken, no matter how clever they seem.
>>
>> Barring huge changes in the design of the internals of gcc, I'm happy
>> with documenting that such pragmas should come before any functions in
>> the source or else they may not apply. That's in line with the "the
>> user shouldn't be doing this unless they absolutely have to" theory.
>
> Putting on my user hat --
>
> I have for years wanted the ability to turn individual warnings off
> for small parts of a file. If I have to put the pragma before all
> the functions -- i.e., if it applies to the whole file, nothing
> smaller -- then I don't think it's worth the effort to implement it.
>
> Seriously. We already have a solution to that problem -- it's
> modifying the command line switches used to compile the file.
Actually, we don't have a solution to that problem. Two things
we don't have:
1. When a user sees a warning message, there's no good
way for them to figure out which command-line switch
controls that warning. The documentation doesn't help.
Even if it did, users shouldn't have to look at it. (The way
I usually figure out which command-line switch goes with
a warning message is by grepping through the source.)
2. Some warnings don't have command-line switches that
control them.
I agree that pragmas are important, but I think we'd better
solve these two problems first before worrying about pragmas.
--Matt
More information about the Gcc
mailing list