https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121185

--- Comment #43 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Mikael Morin <mik...@gcc.gnu.org>:

https://gcc.gnu.org/g:1800ac20f66812c72b144848f7ec8e66156f06f8

commit r16-2567-g1800ac20f66812c72b144848f7ec8e66156f06f8
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Sun Jul 27 17:11:50 2025 +0200

    fortran: Trigger reference saving on pointer dereference [PR121185]

    This is a follow-up to revision:
    r16-2371-g8f41c87654fd819e48c9f6f1ac3d87e35794d310
    fortran: Factor array descriptor references

    That revision introduced new variables to limit repeated subexpressions
    in array descriptor references.  The change added a walk along the
    reference from child to parent, that selected subreferences worth
    saving and applied the saving if the reference proved non-trivial
    enough.  Trivialness was defined in a comment as: only made of a DECL
    and NOPs and COMPONENTs.  But the case of a pointer derefence didn't
    trigger the saving, so the code was also considering a dereference as if
    it was trivial.

    This change triggers the reference saving on pointer dereferences,
    making the trivialness as defined by the code aligned with the comment.

    This change is not strictly speaking a bug fix, but PR #121185 exhibited
    wrong code examples where the lack of a variable hiding the polymorphic
    leading part of a non-polymorphic array reference was causing the latter
    to be evaluated in a polymorphic way.

            PR fortran/121185

    gcc/fortran/ChangeLog:

            * trans-array.cc (set_factored_descriptor_value): Also trigger
            the saving of the previously selected reference on encountering
            an INDIRECT_REF.  Extract the saving code...
            (save_ref): ... here as a new function.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/assign_14.f90: New test.

Reply via email to