[warning control] New #pragma GCC diagnostic

DJ Delorie dj@redhat.com
Wed Jan 18 06:18:00 GMT 2006


Backing up a bit...

> | granularity of control.  We've discussed scope-level control and it's
> | much more complicated, because you end up with a context attached to
> | each tree node.
> 
> Hmm, sorry, I still don't understand.  How is the per-line pragma
> easier to handle than per-function definition pragma.

I said scope-level, not function level.  *Any* scope.  Like a
try/catch block:

foo()
{
  if (some_test)
    _Pragma(error "-Wfoo") {
       /* -Wfoo is an error in this block */
    }
}

We have file-level now (with my pending patch).

We could probably add function level easily.

We could add line level with more work, but without touching half the
files in the compiler.

Adding scope-level would touch half the files in the compiler, if you
wanted to do it right.  For example, if a variable is defined in a
scope with "uninitialized" warnings ignored, but used uninitialized in
a scope where they're errors, what do you do?

At least with line level, you know what to do because the diagnostic
itself tells you where to put the #pragmas.



More information about the Gcc-patches mailing list