[cfe-dev] EXTENSION for some diags

Neil Booth neil at daikokuya.co.uk
Sat Aug 25 22:15:31 PDT 2007


Chris Lattner wrote:-

> You're right, we do.  What do you suggest?  GCC has a class of  
> extension warnings that are emitted by default.  Is this what you  
> mean?  That would give us:
> 
> 1. Error.
> 2. Warning always (eventually enabled or disabled by other -W options)
> 3. Extension, defaults to a warning
> 4. Extension, defaults to silent
> 
> -pedantic would then map #4 to a warning.  -pedantic-errors would  
> make #3/#4 to error.
> 
> Sound reasonable?

I implemented something like the following myself; I'm quite fond
of this approach and it's flexible:

a) Each diagnostic tag has a default severity suitable for normal
   compiles.  Severities are, in order, suppress, remark, warning,
   soft error, hard error, fatal and maybe ice.
b) User can change the severity of any diagnostic with default
   severity <= soft error to any severity <= soft error, either
   via #pragma or on the command line.
c) In C90 and C99 pedantic mode, a table of tags that must
   be diagnosed according to the standard is scanned and the
   severity of said tag "upgraded" to warning (-pedantic or
   equivalent) or error (-pedantic-errors or equivalent) if it
   isn't already.
d) Some severities need to be different depending on compile-
   time context anyway (e.g. integer division by zero is a
   run-time error, compile-time warning except in constant
   expressions where it is compile-time error).  So when
   raising a diagnostic it should be possible for the front
   end to specify a severity override anyway.

You probably feel something slightly different is appropriate
for LLVM, but there may be ideas worth using here.  It avoids
the need for duplicate tags too, which is good from a user-
interface point of view if they are exposed to the user (they
probably should be for the fine-grained control of b)).

Something I've not implemented yet is diagnostic groups, so
you could give groups of tags a name and manipulate them
en-masse, e.g. portability warnings, unused warnings, etc.

Neil.



More information about the cfe-dev mailing list