diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2020-09-30 13:44:39 +0100 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2020-09-30 13:44:39 +0100 |
commit | fcc4891d7f3bff1a3f7428f12830bc942989306c (patch) | |
tree | b26ee228d65681be27def3adf906e19309b11f08 /gcc/fortran/trans-array.c | |
parent | bae974e637421263e8854a69b83284fa6309f9a1 (diff) | |
download | gcc-fcc4891d7f3bff1a3f7428f12830bc942989306c.zip gcc-fcc4891d7f3bff1a3f7428f12830bc942989306c.tar.gz gcc-fcc4891d7f3bff1a3f7428f12830bc942989306c.tar.bz2 |
This patch fixes PR97045 - unlimited polymorphic array element selectors.
2020-30-09 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/97045
* trans-array.c (gfc_conv_array_ref): Make sure that the class
decl is passed to build_array_ref in the case of unlimited
polymorphic entities.
* trans-expr.c (gfc_conv_derived_to_class): Ensure that array
refs do not preceed the _len component. Free the _len expr.
* trans-stmt.c (trans_associate_var): Reset 'need_len_assign'
for polymorphic scalars.
* trans.c (gfc_build_array_ref): When the vptr size is used for
span, multiply by the _len field of unlimited polymorphic
entities, when non-zero.
gcc/testsuite/
PR fortran/97045
* gfortran.dg/select_type_50.f90 : New test.
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 6566c47..998d4d4 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3787,7 +3787,20 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, gfc_expr *expr, decl = sym->backend_decl; } else if (sym->ts.type == BT_CLASS) - decl = NULL_TREE; + { + if (UNLIMITED_POLY (sym)) + { + gfc_expr *class_expr = gfc_find_and_cut_at_last_class_ref (expr); + gfc_init_se (&tmpse, NULL); + gfc_conv_expr (&tmpse, class_expr); + if (!se->class_vptr) + se->class_vptr = gfc_class_vptr_get (tmpse.expr); + gfc_free_expr (class_expr); + decl = tmpse.expr; + } + else + decl = NULL_TREE; + } se->expr = build_array_ref (se->expr, offset, decl, se->class_vptr); } |