From 8a474bd00898ea651831585900d781bef609a3bc Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 31 Aug 2020 09:58:42 +0900 Subject: [PATCH] Ignore "static" and "const" in array-dimensions --- parse.c | 5 ++++- test/compat.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/parse.c b/parse.c index b178928..dc2cd20 100644 --- a/parse.c +++ b/parse.c @@ -575,8 +575,11 @@ static Type *func_params(Token **rest, Token *tok, Type *ty) { return ty; } -// array-dimensions = const-expr? "]" type-suffix +// array-dimensions = ("static" | "restrict")* const-expr? "]" type-suffix static Type *array_dimensions(Token **rest, Token *tok, Type *ty) { + while (equal(tok, "static") || equal(tok, "restrict")) + tok = tok->next; + if (equal(tok, "]")) { ty = type_suffix(rest, tok->next, ty); return array_of(ty, -1); diff --git a/test/compat.c b/test/compat.c index a636204..d085729 100644 --- a/test/compat.c +++ b/test/compat.c @@ -4,6 +4,8 @@ _Noreturn noreturn_fn(int restrict x) { exit(0); } +void funcy_type(int arg[restrict static 3]) {} + int main() { { volatile x; } { int volatile x; }