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

--- Comment #41 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:902a428a99da7cda587c507b6f3a205d495751d7

commit r17-6976-g902a428a99da7cda587c507b6f3a205d495751d7
Author: Mikael Morin <[email protected]>
Date:   Tue Dec 1 11:54:38 2026 +0100

    fortran: array descriptor: Mark polymorphic descriptors as such [PR122521]

    Make sure that when associating a scalar polymorphic reference with an
    assumed rank dummy, the resulting descriptor is initialized with a
    class type.

    Before this change, the descriptor for polymorphic scalar coarrays had a
    type set to derived, that is non-polymorphic, because the type that was
    passed as source for the initialization of the dtype field was not the type
    of the class descriptor.  That source type was taken from the value
    reference which for coarrays matches class->_data.data, that is includes a
    a reference to class container's _data and array descriptor's data fields.
    This is corrected by walking the reference chain up to the class descriptor
    and then using its type for the dtype values.

    The type field of descriptors is hardly used, so I'm not aware of any
    observable behaviour change caused by this, that could be checked by a
    testcase.  There could be a testcase with a tree dump check, but I'm not
    sure how useful that is if there is no observable effect anyway.

            PR fortran/122521

    gcc/fortran/ChangeLog:

            * trans-descriptor.cc (is_polymorphic_ref): New helper.
            (gfc_set_descriptor_from_scalar_class): Find the class descriptor
            ref and always pass its type to build the dtype value from.

Reply via email to