All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cody P Schafer <cody@linux.vnet.ibm.com>
To: linux-sparse@vger.kernel.org
Cc: Cody P Schafer <cody@linux.vnet.ibm.com>
Subject: [PATCH] parse: support c99 [static ...] in abstract array declarators
Date: Tue, 15 Apr 2014 16:08:57 -0700	[thread overview]
Message-ID: <1397603337-28016-1-git-send-email-cody@linux.vnet.ibm.com> (raw)

Makes sparse a little more accepting than the standard: we accept any
number of ["static", "restrict"] repeated in any order, while the n1570
specifies (in 6.7.6.2.3) that either type-qualifiers (ie: "restrict")
come first and are followed by "static" or the opposite ("static" then
type-qualifiers).

Also add a test.

Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
---
 ident-list.h                                  | 1 +
 parse.c                                       | 2 +-
 validation/abstract-array-declarator-static.c | 6 ++++++
 3 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 validation/abstract-array-declarator-static.c

diff --git a/ident-list.h b/ident-list.h
index e93aae7..c0fc18f 100644
--- a/ident-list.h
+++ b/ident-list.h
@@ -91,6 +91,7 @@ IDENT(artificial); IDENT(__artificial__);
 IDENT(leaf); IDENT(__leaf__);
 IDENT(vector_size); IDENT(__vector_size__);
 IDENT(error); IDENT(__error__);
+IDENT(static);
 
 
 /* Preprocessor idents.  Direct use of __IDENT avoids mentioning the keyword
diff --git a/parse.c b/parse.c
index 9cc5f65..cbe3af4 100644
--- a/parse.c
+++ b/parse.c
@@ -1532,7 +1532,7 @@ static struct token *abstract_array_declarator(struct token *token, struct symbo
 {
 	struct expression *expr = NULL;
 
-	if (match_idents(token, &restrict_ident, &__restrict_ident, NULL))
+	while (match_idents(token, &restrict_ident, &__restrict_ident, &static_ident, NULL))
 		token = token->next;
 	token = parse_expression(token, &expr);
 	sym->array_size = expr;
diff --git a/validation/abstract-array-declarator-static.c b/validation/abstract-array-declarator-static.c
new file mode 100644
index 0000000..23cbae0
--- /dev/null
+++ b/validation/abstract-array-declarator-static.c
@@ -0,0 +1,6 @@
+
+extern void f(int g[static 1]);
+
+/*
+ * check-name: abstract array declarator static
+ */
-- 
1.9.2


             reply	other threads:[~2014-04-15 23:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-15 23:08 Cody P Schafer [this message]
2014-04-17  0:12 ` [PATCH] parse: support c99 [static ...] in abstract array declarators Josh Triplett
2014-04-17  3:50   ` Cody P Schafer
2014-04-17  5:09     ` Josh Triplett
2014-04-17  6:50       ` Christopher Li
2014-04-18  5:52         ` Christopher Li
2014-04-21 16:43           ` Cody P Schafer

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=1397603337-28016-1-git-send-email-cody@linux.vnet.ibm.com \
    --to=cody@linux.vnet.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.