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 08/08/2007, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
> On Wed, 8 Aug 2007, Gabriel Dos Reis wrote:
>
> > On Wed, 8 Aug 2007, Kaveh R. GHAZI wrote:
> >
> > | On Wed, 8 Aug 2007, Gabriel Dos Reis wrote:
> > |
> > | > | I am not sure whether this is a good idea since we already have the
> > | > | #pragma GCC diagnostics. But yes, the pragma does not work (yet) at
> > | > | the statement level.
> > | >
> > | > If I understand DJ correctly, they worked at the function definition level;
> > | > that is all we need.  Kaveh, did that not work?
> > | > -- Gaby
> > |
> > | I tried using the #pragma on an inline CONST_CAST function, it did not
> > | work for -Wcast-qual warnings.  I didn't bother trying to see if it worked
> > | for any others.
> > |
> > | #pragma GCC diagnostic ignored "-Wcast-qual"
> > | extern __inline void *CONST_CAST(const void *cv)
> > | {
> > |   return (void *)cv;
> > | }
> > |
> > | % gcc foo.c -Wcast-qual -c
> > | nw.c: In function 'CONST_CAST':
> > | nw.c:4: warning: cast discards qualifiers from pointer target type
> >
> > I believe you have discovered a bug in the compiler :-)
> > -- Gaby
>
> Perhaps.  The documentation says not all warnings are modifiable.  I
> didn't check whether -Wcast-qual is one of them or if this is in fact a
> bug.

The warnings (messages!) that are not modifiable are those that don't
have the first argument of warn() appropriately set. So if that
message is emitted by warn(0, "cast discards...") instead of
warn(OPT_Wcast_qual, "cast discards...") that is a bug and it will be
really good to fix it.

> In addition to what he said,
> you also can't use #pragma in a macro definition.

That is a good argument, though.

> In contrast, the keyword mechanism as shown by the __extension__ feature
> is well tested and has been shown to be useful and usable.  I think a
> __nowarn__ keyword is the way to go and we can break it down to the
> per-warning-flag level as a followup if there is interest by reusing DJ's
> #pragma infrastructure.

__nowarn__("-Wcast-qual") ? It doesn't actually look so bad, does it?

Cheers,

Manuel.


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