diff options
Diffstat (limited to 'gcc/fortran/array.c')
-rw-r--r-- | gcc/fortran/array.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 73b78c3f2fc..a34695e4241 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -1680,25 +1680,29 @@ got_charlen: (without typespec) all elements are verified to have the same length anyway. */ if (found_length != -1) - for (p = expr->value.constructor; p; p = p->next) - if (p->expr->expr_type == EXPR_CONSTANT) - { - gfc_expr *cl = NULL; - int current_length = -1; - - if (p->expr->ts.cl && p->expr->ts.cl->length) - { - cl = p->expr->ts.cl->length; - gfc_extract_int (cl, ¤t_length); - } - - /* If gfc_extract_int above set current_length, we implicitly - know the type is BT_INTEGER and it's EXPR_CONSTANT. */ - - if (! cl - || (current_length != -1 && current_length < found_length)) - gfc_set_constant_character_len (found_length, p->expr, true); - } + for (p = expr->value.constructor; p; p = p->next) + if (p->expr->expr_type == EXPR_CONSTANT) + { + gfc_expr *cl = NULL; + int current_length = -1; + bool has_ts; + + if (p->expr->ts.cl && p->expr->ts.cl->length) + { + cl = p->expr->ts.cl->length; + gfc_extract_int (cl, ¤t_length); + } + + /* If gfc_extract_int above set current_length, we implicitly + know the type is BT_INTEGER and it's EXPR_CONSTANT. */ + + has_ts = (expr->ts.cl && expr->ts.cl->length_from_typespec); + + if (! cl + || (current_length != -1 && current_length < found_length)) + gfc_set_constant_character_len (found_length, p->expr, + has_ts ? -1 : found_length); + } } return SUCCESS; |