diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2021-03-13 11:39:57 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2021-03-13 11:39:57 +0000 |
commit | 7987beec679898cfa75839551d55ae5234a216bd (patch) | |
tree | a22adf3ab5449404f386e1d1a8fe256253e945ce /gcc/fortran/trans-array.c | |
parent | bbdf59fdbc2ce41ccfac807b15cf3fac7b465a56 (diff) | |
download | gcc-7987beec679898cfa75839551d55ae5234a216bd.zip gcc-7987beec679898cfa75839551d55ae5234a216bd.tar.gz gcc-7987beec679898cfa75839551d55ae5234a216bd.tar.bz2 |
Fortran: Fix for class defined operators [PR99125].
2021-03-13 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/99125
* trans-array.c (gfc_conv_expr_descriptor): For deferred length
length components use the ss_info string length instead of
gfc_get_expr_charlen. Make sure that the deferred string length
is a variable before assigning to it. Otherwise use the expr.
* trans-expr.c (gfc_conv_string_length): Make sure that the
deferred string length is a variable before assigning to it.
gcc/testsuite/
PR fortran/99125
* gfortran.dg/alloc_deferred_comp_1.f90: New test.
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 478cddd..be5eb89 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -7670,15 +7670,21 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) /* Set the string_length for a character array. */ if (expr->ts.type == BT_CHARACTER) { - se->string_length = gfc_get_expr_charlen (expr); + if (deferred_array_component) + se->string_length = ss_info->string_length; + else + se->string_length = gfc_get_expr_charlen (expr); + if (VAR_P (se->string_length) && expr->ts.u.cl->backend_decl == se->string_length) tmp = ss_info->string_length; else tmp = se->string_length; - if (expr->ts.deferred) + if (expr->ts.deferred && VAR_P (expr->ts.u.cl->backend_decl)) gfc_add_modify (&se->pre, expr->ts.u.cl->backend_decl, tmp); + else + expr->ts.u.cl->backend_decl = tmp; } /* If we have an array section, are assigning or passing an array |