Re: [PATCH] fortran: Create a dedicated type for ranks and array dimensions

Harald Anlauf <[email protected]> Mon, 6 Jul 2026 22:02:52 +0200
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
Hi Mikael,

On 7/6/26 11:35, Mikael Morin wrote:
> This started as an attempt to remove this annoying usage of
> gfc_conv_descriptor_rank in trans-array.cc(gfc_conv_array_parameter):
> 
>          9278  tree idx = gfc_create_var (TREE_TYPE 
> (gfc_conv_descriptor_rank
>          9279                    (old_desc)),
>          9280                 "idx");
> 
> That snippet was creating a data reference, and then throwing it away to
> only keep the type, which is the type of array descriptors' rank field.
> 
> I could have used just the rank field type directly, but I eventually
> convinced myself that the snippet above showed a lack of a type readily
> available to represent ranks and array dimensions.  This patchs adds
> such a type.
> 
> As usual, I wasn't very inspired when choosing the name for it.  Feel
> free to propose better.
> Regression tested on powerpc64le-unknown-linux-gnu.  OK for master?

this seems to be a nice improvement and looks fine to me.

A stupid question: have you considered a conversion of the result
of gfc_get_cfi_desc_rank already in the getter in trans-array.cc?
This could lead to simpler code in trans-decl.cc::gfc_conv_cfi_to_gfc
where it is used, unless I missed something.

Thanks for the patch!

Harald