From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 399 invoked by alias); 23 Jun 2010 11:45:24 -0000 Received: (qmail 388 invoked by uid 22791); 23 Jun 2010 11:45:24 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jun 2010 11:45:20 +0000 Received: (qmail 9847 invoked from network); 23 Jun 2010 11:45:18 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Jun 2010 11:45:18 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.69) (envelope-from ) id 1OROOL-0000e4-Gn; Wed, 23 Jun 2010 11:45:17 +0000 Date: Wed, 23 Jun 2010 12:24:00 -0000 From: "Joseph S. Myers" To: Shujing Zhao cc: GCC Patches , =?ISO-8859-1?Q?Manuel_L=F3pe?= =?ISO-8859-1?Q?z-Ib=E1=F1ez?= , Paolo Carlini Subject: Re: [PATCH C] Fix pr44517 In-Reply-To: <4C21C7EE.4060805@oracle.com> Message-ID: References: <4C2060CC.3040401@oracle.com> <4C21C7EE.4060805@oracle.com> 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: 2010-06/txt/msg02318.txt.bz2 On Wed, 23 Jun 2010, Shujing Zhao wrote: > > > + error ("unknown type name %qE", token->value); > > > > I don't think %qE is appropriate here if the token is not an identifier. > > > Yes. But the problem is that token->id_kind is C_ID_ID and token->value is > IDENTIFIER_NODE. At function c_lex_one_token, the token->id_kind is always be > set to C_ID_ID if it is not the other identifier. Look at enum c_id_kind, > C_ID_ID is "an ordinary identifier" and there is an "not an identifier" > C_ID_NONE, but it never be really set. If token is CPP_NAME, and it was not > declared as some type name, the token->id_kind should be set C_ID_NONE. But > where should C_ID_ID be set? > I think that is the problem of c_lex_one_token, not the message format. I > can't give a solution for that issue now. Does this patch can be committed > firstly? I don't understand what you are saying. C_ID_NONE is for tokens that are not CPP_NAME at all. C_ID_ID is for a subset of CPP_NAME tokens. Tokens that are not CPP_NAME at all can have many different sorts of trees for token->value, which may not be appropriate for %qE. They may use NULL_TREE if no token value is needed at all. For example, the following test, which should be added to the next patch revision, segfaults with your latest patch applied because you are inappropriately using token->value when it is NULL. As I said, use it *only* for tokens that are some kind of identifier (CPP_NAME or CPP_KEYWORD); include testcases for both CPP_NAME and CPP_KEYWORD and for other kinds of token. void f(int a, *b); > +/* PR c/44517: Improve diagnostic for misspelled typename in function declaration. */ > +int foo(int x, pid_t y, long z, in t) { /* { dg-error "unknown type name 'pid_t'|unknown type name 'in'" } */ > + return x + y + z + t; > +} > + > +int bar(int x, lon y, long z, ...){ /* { dg-error "unknown type name 'lon'" } */ > + return; > +} > + > +void foo(int n, int a[n], pid_t x); /* { dg-error "unknown type name 'pid_t'" } */ > +void bar() {}; Use four different names for the four different functions. Remove the stray semicolon after your last function body. -- Joseph S. Myers joseph@codesourcery.com