]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
allow array size to be inferred from the initializer
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index c1d8cb9c4c1f0b8096bbec6bdab9a023d64cf586..94b254cc91f5a3ad3931fe81d9654e1d738f4047 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1373,6 +1373,11 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
         ast_expression *elemtype = self->expression.next;
         int vtype = elemtype->vtype;
 
+        if (self->expression.flags & AST_FLAG_ARRAY_INIT && !self->expression.count) {
+            compile_error(ast_ctx(self), "array `%s' has no size", self->name);
+            return false;
+        }
+
         /* same as with field arrays */
         if (!self->expression.count || self->expression.count > OPTS_OPTION_U32(OPTION_MAX_ARRAY_SIZE))
             compile_error(ast_ctx(self), "Invalid array of size %lu", (unsigned long)self->expression.count);