https://gcc.gnu.org/g:c6d0d4383e8822c8e63e4b868d0e22c6218ff398
commit c6d0d4383e8822c8e63e4b868d0e22c6218ff398 Author: Mikael Morin <[email protected]> Date: Thu Oct 23 12:32:57 2025 +0200 fortran: array descriptor: Add internal field accessor for data Regression tested on powerpc64le-unknown-linux-gnu. OK for master? -- >8 -- Add a static function producing a reference to the data field of array descriptors, like those existing for the other fields. gcc/fortran/ChangeLog: * trans-descriptor.cc (conv_descriptor_data): New function. (gfc_conv_descriptor_data_get, gfc_conv_descriptor_data_set): Use it. Diff: --- gcc/fortran/trans-descriptor.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index 450d5add38de..78248ac30e85 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -89,6 +89,15 @@ gfc_get_descriptor_field (tree desc, unsigned field_idx) desc, field, NULL_TREE); } + +/* Return a reference to the data field of the array descriptor DESC. */ + +static tree +conv_descriptor_data (tree desc) +{ + return gfc_get_descriptor_field (desc, DATA_FIELD); +} + /* This provides READ-ONLY access to the data field. The field itself doesn't have the proper type. */ @@ -99,7 +108,7 @@ gfc_conv_descriptor_data_get (tree desc) if (TREE_CODE (type) == REFERENCE_TYPE) gcc_unreachable (); - tree field = gfc_get_descriptor_field (desc, DATA_FIELD); + tree field = conv_descriptor_data (desc); return fold_convert (GFC_TYPE_ARRAY_DATAPTR_TYPE (type), field); } @@ -108,7 +117,7 @@ gfc_conv_descriptor_data_get (tree desc) void gfc_conv_descriptor_data_set (stmtblock_t *block, tree desc, tree value) { - tree field = gfc_get_descriptor_field (desc, DATA_FIELD); + tree field = conv_descriptor_data (desc); gfc_add_modify (block, field, fold_convert (TREE_TYPE (field), value)); }
