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

--- Comment #31 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:001f9af67f1adad05abcf9b3e83ecee163fa0f13

commit r17-3736-g001f9af67f1adad05abcf9b3e83ecee163fa0f13
Author: Mikael Morin <[email protected]>
Date:   Fri Aug 28 10:28:20 2026 +0200

    fortran: array descriptor: Move null actual creation [PR122521]

    The creation of a descriptor corresponding to a null() actual argument is
    repeated three times in conv_null_actual to handle three different cases.
    Factor that code to a common function in to trans-descriptor.cc.

    The factored code consisted of calling the scalar descriptor generator,
    and then generating a modification of the descriptor rank.  This was
    producing correct initialization code for the descriptor, but with a
    wrong type and an incorrect zero GFC_TYPE_ARRAY_RANK attached to it.  So
    this change additionnally inlines the scalar descriptor generation,
    replacing the hardcoded zero rank with the true rank passed as argument, so
    that the variable has the right type and is directly generated with the
    correct rank.  With this, the descriptor is bigger because of a non-empty
    array of useless (and uninitialized) dimensions, but it's the type that is
    expected from within the procedure.

    More, the scalar descriptor generation, as an argument passing
    implementation detail, was generating code copying back to the original
    variable on return.  This is not applicable to null() actual arguments and
    this change removes it from the inlined code.  That part actually used to
    cause a gimplification failure for copy back code that looked like this:
        &C.5048 = (void * *) desc.14.data;
    Harald provided a workaround for this with his r15-6408-gd637e6d069ade7 [1]
    null() work, that changed the intent attribute of an argument in one of the
    three places modified here.  This change, having removed the offending
code,
    removes the workaround as well.

    [1]: https://gcc.gnu.org/pipermail/gcc-patches/2024-December/671673.html

            PR fortran/122521

    gcc/fortran/ChangeLog:

            * trans-expr.cc (conv_null_actual): Remove dummy symbol intent
            attribute modification.  Move the three times repeated descriptor
            initialization...
            * trans-descriptor.cc (gfc_create_null_actual_descriptor): ...
            here as a new function and inline the call to
            gfc_conv_scalar_to_descriptor.  Remove the inapplicable or
            redundant parts from the inlined code.  Create lower and upper
            bounds arrays and clear them before passing to the type creation
            function.
            * trans-descriptor.h (gfc_create_null_actual_descriptor): New
            declaration.

Reply via email to