From 5e1b01f35ca68a09de1bc3d5b577fe84342d773d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 13 Sep 2025 22:56:03 +0900 Subject: feat: allow array size to be omitted --- src/parse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/parse.c b/src/parse.c index 82c431a..cc0648a 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1008,8 +1008,11 @@ static int eval(AstNode* e); static Type* parse_array_declarator_suffix(Parser* p, Type* ty) { next_token(p); // skip '[' - AstNode* size_expr = parse_assignment_expr(p); - int size = eval(size_expr); + int size = -1; + if (peek_token(p)->kind != TokenKind_bracket_r) { + AstNode* size_expr = parse_assignment_expr(p); + size = eval(size_expr); + } expect(p, TokenKind_bracket_r); return type_new_array(ty, size); -- cgit v1.2.3-70-g09d2