[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Introduction gfc_init_descriptor_result

Mikael Morin via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:4b3a17ab2caa093b16e6dfaff7cb12d70a0bc2ac

commit 4b3a17ab2caa093b16e6dfaff7cb12d70a0bc2ac
Author: Mikael Morin <[email protected]>
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 | 7 +++++++
 gcc/fortran/trans-descriptor.h  | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 47b28c1d0032..9ad43cd9e7c4 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -4999,14 +4999,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 96e81a7f9883..cf38ed69bb2b 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -883,3 +883,10 @@ gfc_nullify_descriptor (stmtblock_t *block, tree descr)
 {
   gfc_conv_descriptor_data_set (block, descr, null_pointer_node); 
 }
+
+
+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 47b78a43198a..623698382559 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -75,5 +75,6 @@ void gfc_grow_array (stmtblock_t *, tree, tree);
 
 /* Build a null array descriptor constructor.  */
 void gfc_nullify_descriptor (stmtblock_t *block, tree);
+void gfc_init_descriptor_result (stmtblock_t *block, tree descr);
 
 #endif /* GFC_TRANS_DESCRIPTOR_H */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.