diff options
Diffstat (limited to 'gcc/fortran/decl.c')
| -rw-r--r-- | gcc/fortran/decl.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 1a4ca3616dc..021392d427c 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1435,28 +1435,26 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init, bool has_ts; gfc_constructor *ctor = c->initializer->value.constructor; - bool first = true; - int first_len; - has_ts = (c->initializer->ts.cl && c->initializer->ts.cl->length_from_typespec); - for (; ctor; ctor = ctor->next) + if (ctor) { - /* Remember the length of the first element for checking that - all elements *in the constructor* have the same length. This - need not be the length of the LHS! */ - if (first) + int first_len; + + /* Remember the length of the first element for checking + that all elements *in the constructor* have the same + length. This need not be the length of the LHS! */ + gcc_assert (ctor->expr->expr_type == EXPR_CONSTANT); + gcc_assert (ctor->expr->ts.type == BT_CHARACTER); + first_len = ctor->expr->value.character.length; + + for (; ctor; ctor = ctor->next) { - gcc_assert (ctor->expr->expr_type == EXPR_CONSTANT); - gcc_assert (ctor->expr->ts.type == BT_CHARACTER); - first_len = ctor->expr->value.character.length; - first = false; + if (ctor->expr->expr_type == EXPR_CONSTANT) + gfc_set_constant_character_len (len, ctor->expr, + has_ts ? -1 : first_len); } - - if (ctor->expr->expr_type == EXPR_CONSTANT) - gfc_set_constant_character_len (len, ctor->expr, - has_ts ? -1 : first_len); } } } |
