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

--- Comment #42 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Mikael Morin <[email protected]>:

https://gcc.gnu.org/g:e9e8f7221c80ab13e3f66202b48ea313d2c56ac7

commit r17-6977-ge9e8f7221c80ab13e3f66202b48ea313d2c56ac7
Author: Mikael Morin <[email protected]>
Date:   Tue Dec 1 11:54:43 2026 +0100

    fortran: array descriptor: Extract class container with its data pointer
[PR122521]

    In gfc_set_descriptor_from_scalar_class, use a single walk over the input
    reference to extract both the class container and the pointer to the
    underlying data.

    This is a follow-up to the previous change.  That change introduced the
walk
    of the input reference to extract the class container, but it was ignoring
    the change before, that independently checked whether the input reference
    was the class container, to produce a reference to its _data.  This
    integrates the latter into the walk of the input reference.

    The test is a case that isn't covered by the testsuite and failed silently
    with a previous iteration of the patch.

            PR fortran/122521

    gcc/fortran/ChangeLog:

            * trans-descriptor.cc (is_polymorphic_ref): Add argument
valptr_ref.
            Set it to the value pointer reference found during the walk, if
such
            a reference was found.  Otherwise set it to a new reference to the
            _data field of the class container reference.
            (gfc_set_descriptor_from_scalar_class): Add a valptr_ref variable
            and pass it to is_polymorphic_ref.  Don't check the input reference
            type and don't create a new reference to the _data from the input.
            Directly use the reference returned by is_polymorphic_ref instead.

    gcc/testsuite/ChangeLog:

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

Reply via email to