This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: diagnostic.c reorganization
"Joseph S. Myers" <jsm28@cam.ac.uk> writes:
> On Sun, 11 May 2003, Gabriel Dos Reis wrote:
>
>> | +/* A "pedantic" warning. Use this for code which triggers a
>> | + diagnostic which is required by the relevant language
>> | + specification, but which is considered unhelpful (i.e. there isn't
>> | + anything *really* wrong with the construct in the language as she
>> | + is spoke).
>>
>> This comment is unhelpful and inaccurate. Please remove the part
>>
>> (i.e. there isn't anything *really* wrong with the construct in the
>> language as she is spoke).
>>
>> and change "is considered unhelpful" to "GCC consideres too restrictive".
>
> But "considers too restrictive" is still inaccurate - it describes only
> if (pedantic) pedwarn (...). The characterisation of pedwarns is simply
> that the standard requires the diagnostic and that GCC considers that an
> _error_ by default would be too restrictive (except in C++, where pedwarns
> are errors by default). Mandatory pedwarns are for code that is clearly
> wrong but for which there is a clear interpretation that GCC uses to
> compile the code anyway.
How's this text?
A pedantic warning. The effect is the same as "warning" unless
-pedantic-errors was given on the command line, which elevates the
severity to "error". Use this for any diagnostic which is required
by the relevant language standard, but which is not to be an error.
There are two subcategories of pedantic warnings: mandatory and
optional. Mandatory pedwarns are for code which is definitely
wrong per the standard, but the programmer's intent is clear, so
the code can still be compiled. Optional pedwarns are for code
where the standard's requirement is considered too restrictive.
Just calling pedwarn produces a mandatory pedwarn; to get an
optional pedwarn, write "if (pedantic) pedwarn (...);".
It's still kind of vague. Maybe some examples would help ...
zw