From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Subject: [PATCH 9/18] Fix handling of typedefs with several declarators
Date: Mon, 09 Mar 2009 07:11:38 +0000 [thread overview]
Message-ID: <E1LgZeE-0000v3-1P@ZenIV.linux.org.uk> (raw)
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 <viro@zeniv.linux.org.uk>
---
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
+ */
--
1.5.6.5
reply other threads:[~2009-03-09 7:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1LgZeE-0000v3-1P@ZenIV.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).