https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787
--- Comment #6 from anlauf at gcc dot gnu.org ---
WIP patch that fixes comment#5 as like comment#0 and regtests cleanly:
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index 6552eaf3b0c..e1ab2e06fdb 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -1812,6 +1812,29 @@ expand_constructor (gfc_constructor_base base)
continue;
}
+ /* Expand constant array within array constructor. */
+ if (e->expr_type == EXPR_VARIABLE && e->rank && e->ref
+ && e->symtree && e->symtree->n.sym
+ && e->symtree->n.sym->attr.flavor == FL_PARAMETER
+ && e->symtree->n.sym->value
+ && e->symtree->n.sym->value->value.constructor)
+ {
+ gfc_ref *ref;
+ for (ref = e->ref; ref; ref = ref->next)
+ if (ref->type == REF_ARRAY)
+ break;
+
+ if (ref && ref->u.ar.as && ref->u.ar.as->type == AS_EXPLICIT
+ && ref->u.ar.type == AR_FULL)
+ {
+ gfc_expr *value = e->symtree->n.sym->value;
+ if (!expand_constructor (value->value.constructor))
+ return false;
+
+ continue;
+ }
+ }
+
empty_constructor = false;
e = gfc_copy_expr (e);
if (!gfc_simplify_expr (e, 1))
It only lacks goodies such as array sections in the constructor.