https://gcc.gnu.org/g:f033b6affbd634c40c0dd2b8d136605c816d9564
commit f033b6affbd634c40c0dd2b8d136605c816d9564 Author: Mikael Morin <[email protected]> Date: Mon Oct 13 22:25:44 2025 +0200 Correction régression class_elemental_1.f90 Diff: --- gcc/fortran/trans-array.cc | 2 ++ gcc/fortran/trans-expr.cc | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index b520cfd05a67..bac763ba8a46 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -2836,6 +2836,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, && se.expr && GFC_CLASS_TYPE_P (TREE_TYPE (se.expr))) { + ss_info->class_container = se.expr; tree tmp = gfc_class_data_get (se.expr); info->descriptor = tmp; info->data = gfc_conv_descriptor_data_get (tmp); @@ -4059,6 +4060,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar, void gfc_conv_tmp_array_ref (gfc_se * se) { + se->class_container = se->ss->info->class_container; se->string_length = se->ss->info->string_length; gfc_conv_scalarized_array_ref (se, NULL, true); gfc_advance_se_ss_chain (se); diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index c931e798953e..e434637f0c51 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -1234,7 +1234,9 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts, } if ((ref == NULL || class_ref == ref) - && !(gfc_is_class_array_function (e) && parmse->class_vptr != NULL_TREE) + && !(gfc_is_class_array_function (e) + && (parmse->class_vptr != NULL_TREE + || parmse->class_container != NULL_TREE)) && (!class_ts.u.derived->components->as || class_ts.u.derived->components->as->rank != -1)) return; @@ -1316,6 +1318,10 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts, if (gfc_is_class_array_function (e) && parmse->class_vptr != NULL_TREE) tmp = parmse->class_vptr; + else if (parmse->class_container != NULL_TREE) + /* Don't redundantly evaluate the expression if the required information + is already available. */ + tmp = parmse->class_container; else if (class_ref == NULL && e->symtree && e->symtree->n.sym->ts.type == BT_CLASS) { @@ -1329,10 +1335,6 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts, slen = build_zero_cst (size_type_node); } - else if (parmse->class_container != NULL_TREE) - /* Don't redundantly evaluate the expression if the required information - is already available. */ - tmp = parmse->class_container; else { /* Remove everything after the last class reference, convert the
