[PATCH 6/6] allow [*] in array declarators

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

 



Since C99, a '*' is allowed in an abstract array declarator to
specify that the array is a VLA with a yet-to-be-determined size.

So, accept this construction (but still ignore it for now).

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 parse.c                                     | 7 ++++++-
 validation/abstract-array-declarator-star.c | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/parse.c b/parse.c
index c7ca3dce7f6b..6db70f1a95e9 100644
--- a/parse.c
+++ b/parse.c
@@ -1717,7 +1717,12 @@ static struct token *abstract_array_declarator(struct token *token, struct symbo
 		has_static |= (sym->op->type & KW_STATIC);
 		token = token->next;
 	}
-	token = assignment_expression(token, &expr);
+	if (match_op(token, '*') && match_op(token->next, ']')) {
+		// FIXME: '[*]' is treated like '[]'
+		token = token->next;
+	} else {
+		token = assignment_expression(token, &expr);
+	}
 	sym->array_size = expr;
 	return token;
 }
diff --git a/validation/abstract-array-declarator-star.c b/validation/abstract-array-declarator-star.c
index fdbdff19840d..fc42da3ae6c9 100644
--- a/validation/abstract-array-declarator-star.c
+++ b/validation/abstract-array-declarator-star.c
@@ -5,5 +5,4 @@ void ok9(int a[const volatile restrict *]);
 
 /*
  * check-name: abstract-array-declarator-star
- * check-known-to-fail
  */
-- 
2.27.0




[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