]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
error about too many elements in initializer; added test for initialized arrays:...
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index 3d1f30b2203e7ab8c01635e4018c67a6bb8f1b76..c1d8cb9c4c1f0b8096bbec6bdab9a023d64cf586 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1212,6 +1212,16 @@ static bool ast_global_array_set(ast_value *self)
     size_t count = vec_size(self->initlist);
     size_t i;
 
+    if (count > self->expression.count) {
+        compile_error(ast_ctx(self), "too many elements in initializer");
+        count = self->expression.count;
+    }
+    else if (count < self->expression.count) {
+        /* add this?
+        compile_warning(ast_ctx(self), "not all elements are initialized");
+        */
+    }
+
     for (i = 0; i != count; ++i) {
         switch (self->expression.next->vtype) {
             case TYPE_FLOAT: