https://gcc.gnu.org/g:0be670d83c4af299fb721db95c04a5fe19255f2f
commit 0be670d83c4af299fb721db95c04a5fe19255f2f Author: Mikael Morin <mik...@gcc.gnu.org> Date: Sat Jul 19 15:55:36 2025 +0200 Introduction gfc_init_descriptor_result Revert "Suppression gfc_init_descriptor_result" This reverts commit 0f85f1e92970d2a0f13dc61a9781323f33a3b631. Diff: --- gcc/fortran/trans-decl.cc | 4 +--- gcc/fortran/trans-descriptor.cc | 8 ++++++++ gcc/fortran/trans-descriptor.h | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 2cbef72d4a74..0984bd6cbda1 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -4787,14 +4787,12 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) else if (proc_sym == proc_sym->result && IS_CLASS_ARRAY (proc_sym)) { /* Nullify explicit return class arrays on entry. */ - tree type; tmp = get_proc_result (proc_sym); if (tmp && GFC_CLASS_TYPE_P (TREE_TYPE (tmp))) { gfc_start_block (&init); tmp = gfc_class_data_get (tmp); - type = TREE_TYPE (gfc_conv_descriptor_data_get (tmp)); - gfc_conv_descriptor_data_set (&init, tmp, build_int_cst (type, 0)); + gfc_init_descriptor_result (&init, tmp); gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE); } } diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index 76997a28f0bb..73951d2e1b57 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "trans.h" #include "trans-const.h" #include "trans-types.h" +#include "trans-array.h" /******************************************************************************/ @@ -685,3 +686,10 @@ gfc_conv_descriptor_cosize (tree desc, int rank, int corank) { return gfc_conv_descriptor_size_1 (desc, rank, rank + corank - 1); } + + +void +gfc_init_descriptor_result (stmtblock_t *block, tree descr) +{ + gfc_conv_descriptor_data_set (block, descr, null_pointer_node); +} diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h index c035ec638edd..5c0e52762095 100644 --- a/gcc/fortran/trans-descriptor.h +++ b/gcc/fortran/trans-descriptor.h @@ -96,4 +96,6 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off, tree *stride_suboff, tree *lower_suboff, tree *upper_suboff); +void gfc_init_descriptor_result (stmtblock_t *block, tree descr); + #endif /* GFC_TRANS_DESCRIPTOR_H */