aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-09-13 22:56:03 +0900
committernsfisis <nsfisis@gmail.com>2025-09-13 22:56:03 +0900
commit5e1b01f35ca68a09de1bc3d5b577fe84342d773d (patch)
treea1768ea133bb71d9eebde39206e7de7f65f6bda7
parentaae878752e55be9f05dfbde37122e3726527e532 (diff)
downloadducc-5e1b01f35ca68a09de1bc3d5b577fe84342d773d.tar.gz
ducc-5e1b01f35ca68a09de1bc3d5b577fe84342d773d.tar.zst
ducc-5e1b01f35ca68a09de1bc3d5b577fe84342d773d.zip
feat: allow array size to be omitted
-rw-r--r--src/parse.c7
1 files 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);