https://gcc.gnu.org/g:e5527ccf4a8f403be607b52e8a32915bcce073f9

commit e5527ccf4a8f403be607b52e8a32915bcce073f9
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 | 24 ++++++++++++++++++++++++
 gcc/fortran/trans-descriptor.h  |  4 ++--
 3 files changed, 28 insertions(+), 18 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 83e2c83826d1..b34eded44af3 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -638,3 +638,27 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, 
tree *data_off,
 #undef STRIDE_SUBFIELD
 #undef LBOUND_SUBFIELD
 #undef UBOUND_SUBFIELD
+
+
+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 3f602219c284..6058f54fc5fd 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -22,9 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Build a null array descriptor constructor.  */
 tree gfc_build_null_descriptor (tree);
 tree gfc_build_default_class_descriptor (tree, gfc_typespec &);
-void gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *, tree);
 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 *);
@@ -94,4 +92,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_variable (stmtblock_t *block, gfc_symbol *sym, tree 
descr);
+
 #endif /* GFC_TRANS_DESCRIPTOR_H */

Reply via email to