diff options
author | Peter Hill <peter.hill@york.ac.uk> | 2024-02-20 20:42:53 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2024-02-20 20:50:01 +0100 |
commit | 14ba8d5b87acd5f91ab8b8c02165a0fd53dcc2f2 (patch) | |
tree | 1cd6ed4471bac28787b4a5496001c984638140b1 /gcc/fortran/trans-expr.cc | |
parent | 81e5f276c59897077ffe38202849c93e9c580c41 (diff) | |
download | gcc-14ba8d5b87acd5f91ab8b8c02165a0fd53dcc2f2.zip gcc-14ba8d5b87acd5f91ab8b8c02165a0fd53dcc2f2.tar.gz gcc-14ba8d5b87acd5f91ab8b8c02165a0fd53dcc2f2.tar.bz2 |
Fortran: fix passing array component ref to polymorphic procedures
PR fortran/105658
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_conv_intrinsic_to_class): When passing an
array component reference of intrinsic type to a procedure
with an unlimited polymorphic dummy argument, a temporary
should be created.
gcc/testsuite/ChangeLog:
* gfortran.dg/PR105658.f90: New test.
Signed-off-by: Peter Hill <peter.hill@york.ac.uk>
Diffstat (limited to 'gcc/fortran/trans-expr.cc')
-rw-r--r-- | gcc/fortran/trans-expr.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 3506e4e..118dfd7 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -1019,6 +1019,14 @@ gfc_conv_intrinsic_to_class (gfc_se *parmse, gfc_expr *e, tmp = gfc_typenode_for_spec (&class_ts); var = gfc_create_var (tmp, "class"); + /* Force a temporary for component or substring references. */ + if (unlimited_poly + && class_ts.u.derived->components->attr.dimension + && !class_ts.u.derived->components->attr.allocatable + && !class_ts.u.derived->components->attr.class_pointer + && is_subref_array (e)) + parmse->force_tmp = 1; + /* Set the vptr. */ ctree = gfc_class_vptr_get (var); |