[PATCH] parse: support c99 [static ...] in abstract array declarators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux