Re: [PATCH] fortran: Fix derived type rank not set for allocate mold

Jerry D <[email protected]> Wed, 8 Jul 2026 16:15:45 -0700
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
Pushed

commit 9decb8a07ac764f2a39885b2a5905515f188da06 (HEAD -> master, origin/master, 
origin/HEAD)
Author: Jerry DeLisle <[email protected]>
Date:   Wed Jul 8 08:52:25 2026 -0700

     fortran: Fix derived type rank not set for allocate mold

     When mold was being used in the allocate of an array within
     a derived type, the rank was not getting set.

     gcc/fortran/ChangeLog:

             * trans-array.cc (gfc_array_init_size): Set the rank for the
             dtype.

     gcc/testsuite/ChangeLog:

             * gfortran.dg/allocate_with_mold_6.f90: New test.
             * gfortran.dg/allocate_with_mold_7.f90: New test.


On 7/8/26 9:16 AM, Jerry D wrote:
> The attached patch is simple and obvious. Andrew sent me the use case off-list. 
> I will commit this later this afternoon if no objections.
> 
> Regression tested on x86_64.
> 
> Thanks Andrew for the example. Two new testcases added.
> 
> Regards,
> 
> Jerry
> ---
>      fortran: Fix derived type rank not set for allocate mold
> 
>      When mold was being used in the allocate of an array within
>      a derived type, the rank was not getting set.
> 
>      gcc/fortran/ChangeLog:
> 
>              * trans-array.cc (gfc_array_init_size): Set the rank for the
>              dtype.
> 
>      gcc/testsuite/ChangeLog:
> 
>              * gfortran.dg/allocate_with_mold_6.f90: New test.
>              * gfortran.dg/allocate_with_mold_7.f90: New test.
> ---