aboutsummaryrefslogtreecommitdiff
path: root/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'decl.c')
-rw-r--r--decl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/decl.c b/decl.c
index 7047dda..81130f3 100644
--- a/decl.c
+++ b/decl.c
@@ -450,6 +450,7 @@ declaratortypes(struct scope *s, struct list *result, char **name, bool allowabs
struct list *ptr;
struct type *t;
struct param **p;
+ struct expr *e;
uint64_t i;
enum typequal tq;
@@ -547,7 +548,13 @@ declaratortypes(struct scope *s, struct list *result, char **name, bool allowabs
i = 0;
next();
} else {
- i = intconstexpr(s, false);
+ e = constexpr(s);
+ if (e->kind != EXPRCONST || !(e->type->prop & PROPINT))
+ error(&tok.loc, "VLAs are not yet supported");
+ i = e->constant.i;
+ if (i == 0 || e->type->basic.issigned && i > INT64_MAX)
+ error(&tok.loc, "array length must be positive");
+ delexpr(e);
expect(TRBRACK, "after array length");
}
t = mkarraytype(NULL, tq, i);