https://gcc.gnu.org/g:3937e01b4eba511a4a5fd2bcd0c81c62fe3ec68a
commit r13-9165-g3937e01b4eba511a4a5fd2bcd0c81c62fe3ec68a Author: Paul Thomas <pa...@gcc.gnu.org> Date: Sun Nov 3 15:45:32 2024 +0000 Fortran: Fix regression in 13-branch due to pr113363.f90 [PR116040] 2023-11-03 Paul Thomas <pa...@gcc.gnu.org> gcc/fortran PR fortran/116040 * trans-stmt.cc (trans_associate_var): Copy chunk in 14-branch that correctly handles class function selectors. Diff: --- gcc/fortran/trans-stmt.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index 11a8a9c74ca6..51d008cacb8d 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -2039,7 +2039,16 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block) /* Class associate-names come this way because they are unconditionally associate pointers and the symbol is scalar. */ - if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->attr.dimension) + if (sym->ts.type == BT_CLASS && e->expr_type == EXPR_FUNCTION) + { + gfc_conv_expr (&se, e); + se.expr = gfc_evaluate_now (se.expr, &se.pre); + /* Finalize the expression and free if it is allocatable. */ + gfc_finalize_tree_expr (&se, NULL, gfc_expr_attr (e), e->rank); + gfc_add_block_to_block (&se.post, &se.finalblock); + need_len_assign = false; + } + else if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->attr.dimension) { tree target_expr; /* For a class array we need a descriptor for the selector. */