aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index c4ef7e7..a1c7d5a 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -5820,10 +5820,27 @@ do_parm (void)
&& sym->ts.cl->length != NULL
&& sym->ts.cl->length->expr_type == EXPR_CONSTANT
&& init->expr_type == EXPR_CONSTANT
- && init->ts.type == BT_CHARACTER
- && init->ts.kind == 1)
+ && init->ts.type == BT_CHARACTER)
gfc_set_constant_character_len (
mpz_get_si (sym->ts.cl->length->value.integer), init, false);
+ else if (sym->ts.type == BT_CHARACTER && sym->ts.cl != NULL
+ && sym->ts.cl->length == NULL)
+ {
+ int clen;
+ if (init->expr_type == EXPR_CONSTANT)
+ {
+ clen = init->value.character.length;
+ sym->ts.cl->length = gfc_int_expr (clen);
+ }
+ else if (init->expr_type == EXPR_ARRAY)
+ {
+ gfc_expr *p = init->value.constructor->expr;
+ clen = p->value.character.length;
+ sym->ts.cl->length = gfc_int_expr (clen);
+ }
+ else if (init->ts.cl && init->ts.cl->length)
+ sym->ts.cl->length = gfc_copy_expr (sym->value->ts.cl->length);
+ }
sym->value = init;
return MATCH_YES;