diff options
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r-- | gcc/fortran/trans-decl.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b8f50f7..9a8f2d3 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -5399,6 +5399,33 @@ generate_coarray_sym_init (gfc_symbol *sym) /* Handle "static" initializer. */ if (sym->value) { + if (sym->value->expr_type == EXPR_ARRAY) + { + gfc_constructor *c, *cnext; + + /* Test if the array has more than one element. */ + c = gfc_constructor_first (sym->value->value.constructor); + gcc_assert (c); /* Empty constructor should not happen here. */ + cnext = gfc_constructor_next (c); + + if (cnext) + { + /* An EXPR_ARRAY with a rank > 1 here has to come from a + DATA statement. Set its rank here as not to confuse + the following steps. */ + sym->value->rank = 1; + } + else + { + /* There is only a single value in the constructor, use + it directly for the assignment. */ + gfc_expr *new_expr; + new_expr = gfc_copy_expr (c->expr); + gfc_free_expr (sym->value); + sym->value = new_expr; + } + } + sym->attr.pointer = 1; tmp = gfc_trans_assignment (gfc_lval_expr_from_sym (sym), sym->value, true, false); |