Hi Andrew and Jerry, The proposed patch is simple and works as intended. I was unable to find a more elegant alternative.
OK to push. Thanks for the patch. Paul On Sat, 24 Jan 2026 at 03:16, Jerry D <[email protected]> wrote: > > Hi all, > > The attached patch and new test case provided by Andrew Benson. > > Regression tested on x86_64-linux-gnu. > > OK for mainline? > > Date: Fri Jan 23 18:52:34 2026 -0800 > > Fortran: Fix missed finalization > > PR fortran/123772 > > gcc/fortran/ChangeLog: > > * trans.cc: Add global variable is_assign_call. > (gfc_finalize_tree_expr): Derived type function results > with components that have defined assignements are > handled in resolve.cc(generate_component_assignments), unless > the assignment was replaced by a subroutine call to the > subroutine associated with the assignment operator. > (trans_code): In the case of EXEC_ASSIGN_CALL, set the > is_asign_call before calling gfc_trans_call, then clear it > after. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/pr123772.f03: New test. > > Signed off by: Andrew Benson <[email protected]>
