From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Subject: [PATCH 3/7] More nested declarator fixes
Date: Sat, 14 Feb 2009 12:25:25 +0000 [thread overview]
Message-ID: <E1LYJaH-0001nA-Kl@ZenIV.linux.org.uk> (raw)
no nested declarators after [...] or (parameters)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
parse.c | 2 ++
validation/nested-declarator.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/parse.c b/parse.c
index 86e26aa..1678d80 100644
--- a/parse.c
+++ b/parse.c
@@ -1295,6 +1295,7 @@ static struct token *direct_declarator(struct token *token, struct symbol *decl,
token = parameter_type_list(next, sym, p);
token = expect(token, ')', "in function declarator");
sym->endpos = token->pos;
+ dont_nest = 1;
continue;
}
if (token->special == '[') {
@@ -1303,6 +1304,7 @@ static struct token *direct_declarator(struct token *token, struct symbol *decl,
token = expect(token, ']', "in abstract_array_declarator");
array->endpos = token->pos;
ctype = &array->ctype;
+ dont_nest = 1;
continue;
}
break;
diff --git a/validation/nested-declarator.c b/validation/nested-declarator.c
index 24ed833..1e69823 100644
--- a/validation/nested-declarator.c
+++ b/validation/nested-declarator.c
@@ -6,6 +6,22 @@ static void g(int x)
T = x;
f(T);
}
+static void h(void)
+{
+ static int [2](T)[3];
+}
+static int [2](*p)[3];
+int i(void (void)(*f));
+int j(int [2](*));
/*
* check-name: nested declarator vs. parameters
+ * check-error-start:
+nested-declarator.c:11:22: warning: missing identifier in declaration
+nested-declarator.c:13:16: error: Expected ) in function declarator
+nested-declarator.c:13:16: error: got *
+nested-declarator.c:14:19: error: Expected ) in function declarator
+nested-declarator.c:14:19: error: got *
+nested-declarator.c:15:15: error: Expected ) in function declarator
+nested-declarator.c:15:15: error: got *
+ * check-error-end:
*/
--
1.5.6.6
reply other threads:[~2009-02-14 12:25 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=E1LYJaH-0001nA-Kl@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).