From patchwork Mon Mar 9 07:11:38 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 10627 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n297Ao9f002408 for ; Mon, 9 Mar 2009 07:11:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752733AbZCIHLk (ORCPT ); Mon, 9 Mar 2009 03:11:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752777AbZCIHLk (ORCPT ); Mon, 9 Mar 2009 03:11:40 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:43752 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752733AbZCIHLj (ORCPT ); Mon, 9 Mar 2009 03:11:39 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.69 #1 (Red Hat Linux)) id 1LgZeE-0000v3-1P for linux-sparse@vger.kernel.org; Mon, 09 Mar 2009 07:11:38 +0000 To: linux-sparse@vger.kernel.org Subject: [PATCH 9/18] Fix handling of typedefs with several declarators Message-Id: From: Al Viro Date: Mon, 09 Mar 2009 07:11:38 +0000 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org We set MOD_USERTYPE only on the first one, so declaration_specifiers didn't recognize something like unsigned P; where P had been such a typedef as redefinition (see the testcase). Signed-off-by: Al Viro --- parse.c | 3 +++ validation/multi_typedef.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) create mode 100644 validation/multi_typedef.c diff --git a/parse.c b/parse.c index 7b1cfb6..1435fde 100644 --- a/parse.c +++ b/parse.c @@ -2365,6 +2365,9 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis return token; } + if (is_typedef) + decl->ctype.modifiers |= MOD_USERTYPE; + bind_symbol(decl, ident, is_typedef ? NS_TYPEDEF: NS_SYMBOL); /* Function declarations are automatically extern unless specifically static */ diff --git a/validation/multi_typedef.c b/validation/multi_typedef.c new file mode 100644 index 0000000..d9ffd0f --- /dev/null +++ b/validation/multi_typedef.c @@ -0,0 +1,15 @@ +typedef int T, *P; +static void f(void) +{ + unsigned P = 0; + unsigned x = P; +} +static void g(void) +{ + int P = 0; + int x = P; +} +/* + * check-name: typedefs with many declarators + * check-description: we didn't recognize P above as a typedef + */