From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20593 invoked by alias); 8 Aug 2007 19:42:04 -0000 Received: (qmail 20569 invoked by uid 22791); 8 Aug 2007 19:42:03 -0000 X-Spam-Check-By: sourceware.org Received: from mailhost.cs.tamu.edu (HELO postal.cs.tamu.edu) (128.194.138.100) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 08 Aug 2007 19:41:55 +0000 Received: from gauss.cs.tamu.edu (gauss.cs.tamu.edu [128.194.146.28]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by postal.cs.tamu.edu (Postfix) with ESMTP id F03C346DE01; Wed, 8 Aug 2007 14:41:53 -0500 (CDT) Date: Wed, 08 Aug 2007 19:42:00 -0000 From: Gabriel Dos Reis To: "Kaveh R. GHAZI" cc: Paolo Bonzini , =?ISO-8859-1?Q?Manuel_L=F3pez-Ib=E1=F1ez?= , Mark Mitchell , gcc-patches@gcc.gnu.org Subject: Re: Add a __nowarn__ keyword In-Reply-To: Message-ID: References: <46B6B038.7050601@codesourcery.com> <46B741C7.4080908@codesourcery.com> <6c33472e0708080152i1fd84566pe806fc83f40df417@mail.gmail.com> <6c33472e0708080729n4d59f0bdn72a90a95a7881ad3@mail.gmail.com> <46B9F0B5.1080302@gnu.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-08/txt/msg00537.txt.bz2 On Wed, 8 Aug 2007, Kaveh R. GHAZI wrote: | On Wed, 8 Aug 2007, Paolo Bonzini wrote: | | > > 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. | > | > I believe these were preapproved, weren't they? | > | > >> In addition to what he said, | > >> you also can't use #pragma in a macro definition. | > | > You can, it's _Pragma("foo"). | > Paolo | | (Ok, imagine I just had a head-smacking "Doh!" moment.) | | So this is encouraging, I added OPT_Wcast_qual to the warning statement | and now it obeys the #pragma (or _Pragma). Fantastic! | However I'm still having one | last problem. The pragma interface is still on/off, not push/pop. I.e.: | | #pragma GCC diagnostic ignored "-Wcast-qual" | extern __inline void *CONST_CAST(const void *cv) | { | return (void *)cv; | } | //#pragma GCC diagnostic error "-Wcast-qual" | | void foo (const void *cv) | { | void *v = CONST_CAST(cv); // WARNING1 | void *v2 = (void *)cv; // WARNING2 | } | | Assuming you've corrected the missing OPT_Wcast_qual in c-typeck.c, if you | compile the above with -Wcast-qual -Werror, the code correctly avoids the | warnings on the line marked WARNING1. However we should still get a | warning for WARNING2 but we don't. I believe the pragma has changed the | behavior of gcc for the rest of the entire file. There is no "pop" at the | end of the inline function CONST_CAST. Yes, the missing "pop" is a bug. There should be one in the machinery. | In order to see WARNING2, I have to uncomment the second pragma. But this | is bad IMHO because it overrides the command line. I fully agree. We should have the equivalent of #pragma GCC diagnostic restore of that CONST_CAST could be written: #pragma GCC diagnostic ignored "-Wcast-qual" extern __inline void *CONST_CAST(const void *cv) { return (void *)cv; } #pragma GCC diagnostic restore -- Gaby