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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

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

commit r17-5522-geb6649a97d7a75b08d6c963ce99ddad9654b3aa9
Author: Jerry DeLisle <[email protected]>
Date:   Sun Oct 4 16:21:46 2026 -0700

    fortran: [PR127731] Index pointer function results by their span

    A pointer array function can return a descriptor whose span is larger
    than the element size, for instance when the result points to a
    component of a derived-type array or to the real part of a complex array.
    Callers ignored that span: the result temporary was indexed by the
    element size, an associate name or pointer associated with the result
    was not marked as a subreference array pointer, and an actual argument
    was passed on without being packed.  The patch marks the result
    temporary GFC_DECL_PTR_ARRAY_P, sets subref_array_pointer on the
    associate name and on the pointer object, and passes a pointer result
    to a non-pointer dummy through gfc_conv_subref_array_arg, which makes a
    packed copy when the span differs from the element size.

    Assisted-by: Claude Opus 5.5

            PR fortran/127731

    gcc/fortran/ChangeLog:

            * expr.cc (gfc_check_pointer_assign): Set subref_array_pointer
            on the pointer object when the target is a pointer array
            function result.
            * resolve.cc (resolve_assoc_var): Likewise on the associate name
            when the selector is a pointer array function result.
            * trans-expr.cc (pointer_array_result_p): New function.
            (pointer_result_var): New function.
            (gfc_conv_procedure_call): Pass a pointer array function result
            to a non-pointer dummy through gfc_conv_subref_array_arg.  Mark
            the temporary for a pointer array result GFC_DECL_PTR_ARRAY_P.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pointer_function_span_1.f90: New test.
            * gfortran.dg/pointer_function_span_2.f90: New test.

Reply via email to