https://gcc.gnu.org/g:ce7f5e4a7ab51e55e3b45add273101022c988c82
commit ce7f5e4a7ab51e55e3b45add273101022c988c82 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Tue Jul 15 18:28:30 2025 +0200 Extraction gfc_init_descriptor_variable Correction nom block Correction libgomp.fortran/allocators-1.f90 Renommage gfc_clear_descriptor -> gfc_init_descriptor_variable Diff: --- gcc/fortran/trans-array.cc | 18 ++---------------- gcc/fortran/trans-descriptor.cc | 23 +++++++++++++++++++++++ gcc/fortran/trans-descriptor.h | 3 ++- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 0d8beebbb431..8e4a347d1186 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -11907,10 +11907,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block) /* NULLIFY the data pointer for non-saved allocatables, or for non-saved pointers when -fcheck=pointer is specified. */ if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save - && (sym->attr.allocatable - || (sym->attr.pointer && (gfc_option.rtcheck & GFC_RTCHECK_POINTER)))) + && (sym->attr.allocatable || sym->attr.pointer)) { - gfc_conv_descriptor_data_set (&init, descriptor, null_pointer_node); if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension) { /* Declare the variable static so its array descriptor stays present @@ -11918,22 +11916,10 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block) image. This may happen, for example, with the caf_mpi implementation. */ TREE_STATIC (descriptor) = 1; - gfc_conv_descriptor_token_set (&init, descriptor, null_pointer_node); } + gfc_init_descriptor_variable (&init, sym, descriptor); } - /* Set initial TKR for pointers and allocatables */ - if (GFC_DESCRIPTOR_TYPE_P (type) - && (sym->attr.pointer || sym->attr.allocatable)) - { - tree etype; - - gcc_assert (sym->as && sym->as->rank>=0); - etype = gfc_get_element_type (type); - gfc_conv_descriptor_dtype_set (&init, descriptor, - gfc_get_dtype_rank_type (sym->as->rank, - etype)); - } input_location = loc; gfc_init_block (&cleanup); diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index de7cea9e397f..684b81143b17 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -660,3 +660,26 @@ gfc_nullify_descriptor (stmtblock_t *block, tree descr) gfc_conv_descriptor_data_set (block, descr, null_pointer_node); } + +void +gfc_init_descriptor_variable (stmtblock_t *block, gfc_symbol *sym, tree descr) +{ + /* NULLIFY the data pointer for non-saved allocatables, or for non-saved + pointers when -fcheck=pointer is specified. */ + if (sym->attr.allocatable + || (sym->attr.pointer && (gfc_option.rtcheck & GFC_RTCHECK_POINTER))) + { + gfc_conv_descriptor_data_set (block, descr, null_pointer_node); + if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension) + gfc_conv_descriptor_token_set (block, descr, null_pointer_node); + } + + tree etype; + + gcc_assert (sym->as && sym->as->rank>=0); + etype = gfc_get_element_type (TREE_TYPE (descr)); + gfc_conv_descriptor_dtype_set (block, descr, + gfc_get_dtype_rank_type (sym->as->rank, + etype)); +} + diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h index b983a3f7bc53..4099c9805890 100644 --- a/gcc/fortran/trans-descriptor.h +++ b/gcc/fortran/trans-descriptor.h @@ -21,7 +21,6 @@ along with GCC; see the file COPYING3. If not see /* Build a null array descriptor constructor. */ void gfc_nullify_descriptor (stmtblock_t *block, gfc_expr *, tree); -void gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *, gfc_expr *, tree); void gfc_set_scalar_null_descriptor (stmtblock_t *block, tree, gfc_symbol *, gfc_expr *, tree); void gfc_set_descriptor_with_shape (stmtblock_t *, tree, tree, gfc_expr *, locus *); @@ -96,4 +95,6 @@ void gfc_init_absent_descriptor (stmtblock_t *block, tree descr); /* Build a null array descriptor constructor. */ void gfc_nullify_descriptor (stmtblock_t *block, tree); +void gfc_init_descriptor_variable (stmtblock_t *block, gfc_symbol *sym, tree descr); + #endif /* GFC_TRANS_DESCRIPTOR_H */