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

commit fce2dae704ee69f8aa491d0acf72c46dbb6aeff0
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Jul 18 15:26:18 2025 +0200

    Revert "Factorisation gfc_set_contiguous_descriptor"
    
    This reverts commit ed42e9d37173dc774265ac9febb48fdea993ac48.

Diff:
---
 gcc/fortran/trans-array.cc      | 40 ++++++++++++++++++++++++++++------------
 gcc/fortran/trans-descriptor.cc | 16 ----------------
 gcc/fortran/trans-descriptor.h  |  2 --
 3 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index f071a5fc9220..c76dd32fb95a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -9466,6 +9466,32 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, 
tree dest,
              ubound = build_int_cst (gfc_array_index_type, 1);
            }
 
+         /* Treat strings like arrays.  Or the other way around, do not
+          * generate an additional array layer for scalar components.  */
+         if (attr->dimension || c->ts.type == BT_CHARACTER)
+           {
+             cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node,
+                                                &ubound, 1,
+                                                GFC_ARRAY_ALLOCATABLE, false);
+
+             cdesc = gfc_create_var (cdesc, "cdesc");
+             DECL_ARTIFICIAL (cdesc) = 1;
+
+             gfc_conv_descriptor_dtype_set (&tmpblock, cdesc,
+                                            gfc_get_dtype_rank_type (1, tmp));
+             gfc_conv_descriptor_lbound_set (&tmpblock, cdesc,
+                                             gfc_index_zero_node,
+                                             gfc_index_one_node);
+             gfc_conv_descriptor_stride_set (&tmpblock, cdesc,
+                                             gfc_index_zero_node,
+                                             gfc_index_one_node);
+             gfc_conv_descriptor_ubound_set (&tmpblock, cdesc,
+                                             gfc_index_zero_node, ubound);
+           }
+         else
+           /* Prevent warning.  */
+           cdesc = NULL_TREE;
+
          if (attr->dimension)
            {
              if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp)))
@@ -9488,23 +9514,13 @@ structure_alloc_comps (gfc_symbol * der_type, tree 
decl, tree dest,
              gfc_add_block_to_block (&tmpblock, &se.pre);
            }
 
-         /* Treat strings like arrays.  Or the other way around, do not
-          * generate an additional array layer for scalar components.  */
          if (attr->dimension || c->ts.type == BT_CHARACTER)
-           {
-             cdesc = gfc_get_array_type_bounds (tmp, 1, 0, &gfc_index_one_node,
-                                                &ubound, 1,
-                                                GFC_ARRAY_ALLOCATABLE, false);
-
-             cdesc = gfc_create_var (cdesc, "cdesc");
-             DECL_ARTIFICIAL (cdesc) = 1;
-
-             gfc_set_contiguous_descriptor (&tmpblock, cdesc, ubound, comp);
-           }
+           gfc_conv_descriptor_data_set (&tmpblock, cdesc, comp);
          else
            cdesc = comp;
 
          tree fndecl;
+
          fndecl = build_call_expr_loc (input_location,
                                        gfor_fndecl_co_broadcast, 5,
                                        gfc_build_addr_expr 
(pvoid_type_node,cdesc),
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 91b71679dc9c..bf799fb3e467 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1343,19 +1343,3 @@ gfc_set_descriptor (stmtblock_t *block, tree dest, tree 
src, gfc_expr *src_expr,
 }
  
 
-void
-gfc_set_contiguous_descriptor (stmtblock_t *block, tree desc, tree size,
-                              tree data_ptr)
-{
-  gfc_conv_descriptor_dtype_set (block, desc,
-                               gfc_get_dtype_rank_type (1, TREE_TYPE (desc)));
-  gfc_conv_descriptor_lbound_set (block, desc,
-                                 gfc_index_zero_node,
-                                 gfc_index_one_node);
-  gfc_conv_descriptor_stride_set (block, desc,
-                                 gfc_index_zero_node,
-                                 gfc_index_one_node);
-  gfc_conv_descriptor_ubound_set (block, desc,
-                                 gfc_index_zero_node, size);
-  gfc_conv_descriptor_data_set (block, desc, data_ptr);
-}
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 70238dd1001e..884cd0d11a02 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -111,7 +111,5 @@ void gfc_copy_descriptor (stmtblock_t *, tree, tree, 
gfc_expr *, bool);
 void gfc_set_descriptor (stmtblock_t *, tree, tree, gfc_expr *, int, int,
                         gfc_ss *, gfc_array_info *, tree [GFC_MAX_DIMENSIONS],
                         tree [GFC_MAX_DIMENSIONS], bool, bool, bool);
-void gfc_set_contiguous_descriptor (stmtblock_t *, tree, tree, tree);
-
 
 #endif /* GFC_TRANS_DESCRIPTOR_H */

Reply via email to