From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18077 invoked by alias); 16 Oct 2002 00:35:08 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 18037 invoked from network); 16 Oct 2002 00:35:08 -0000 Received: from unknown (HELO egil.codesourcery.com) (66.92.14.122) by sources.redhat.com with SMTP; 16 Oct 2002 00:35:08 -0000 Received: from zack by egil.codesourcery.com with local (Exim 3.36 #1 (Debian)) id 181c9T-0007LF-00; Tue, 15 Oct 2002 17:35:07 -0700 Date: Tue, 15 Oct 2002 19:11:00 -0000 To: Mark Mitchell Cc: Joe Buck , "gcc@gcc.gnu.org" Subject: Re: gcc 3.2.1 draft release notes, 3rd draft Message-ID: <20021016003507.GL15067@codesourcery.com> References: <200210151621.g9FGLIF19813@piper.synopsys.com> <59720000.1034701726@warlock.codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59720000.1034701726@warlock.codesourcery.com> User-Agent: Mutt/1.4i From: Zack Weinberg X-SW-Source: 2002-10/txt/msg00906.txt.bz2 On Tue, Oct 15, 2002 at 10:08:46AM -0700, Mark Mitchell wrote: > >Then how about adding a rule something like the following to the bison > >grammar (yes, I know these are the wrong terminal names, but the idea > >should be clear): > > > > TYPEDEF ID '=' error ';' > > { error("Please use __typeof() instead");} > > Along these lines, one could perhaps even do the transformation at that > point. > > TYPEDEF ID = expression ; > > { /* Do whatever you do for the typeof case. */ } It's worth pointing out that the grammar does not distinguish between typedef declarations and other declarations. It's all handled by datadef: declspecs declarator '=' init ';' (simplified for clarity) The present error message comes from the semantics layer, c-decl.c:start_decl(): if (initialized) /* Is it valid for this decl to have an initializer at all? If not, set INITIALIZED to zero, which will indirectly tell `finish_decl' to ignore the initializer once it is parsed. */ switch (TREE_CODE (decl)) { case TYPE_DECL: error ("typedef `%s' is initialized", IDENTIFIER_POINTER (DECL_NAME (decl))); initialized = 0; break; It would be easy to insert in here advice ("Please use __typeof() instead"); ("advice" is a diagnostic category I propose for helpful advice, such as this, or the "Each undeclared identifier is reported only once" message, which can be shut up with -fno-advice; right now, imagine that it reads "error") "Trying to do the above transformation" boils down to my original patch that fixed the bug in the extension. zw