From 51e2f98e33ae10fc3052335cc6847bc93d0784fa Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 14 Jul 2026 01:45:58 +0200 Subject: Add static array initializer --- gcc/gcc/elna-generic.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gcc') diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 5749bbc..928ca8d 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -202,6 +202,28 @@ namespace elna::gcc this->current_expression = build_constructor(record_type, tree_arguments); } + void generic_visitor::visit(boot::array_constructor_expression *expression) + { + tree array_type = get_inner_alias(expression->type_decoration, this->symbols); + + if (TREE_CODE(array_type) != ARRAY_TYPE) + { + this->current_expression = error_mark_node; + return; + } + tree domain = TYPE_DOMAIN(array_type); + tree index = TYPE_MIN_VALUE(domain); + vec *tree_arguments = nullptr; + + for (boot::expression *const element : expression->elements) + { + element->accept(this); + CONSTRUCTOR_APPEND_ELT(tree_arguments, index, this->current_expression); + index = int_const_binop(PLUS_EXPR, index, size_one_node); + } + this->current_expression = build_constructor(array_type, tree_arguments); + } + void generic_visitor::visit(boot::unit *unit) { for (boot::import_declaration *const declaration : unit->imports) -- cgit v1.2.3