[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Extraction gfc_copy_sequence_descriptor

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

commit 887ce6387776cd33258cd031330fec62da5c1b2c
Author: Mikael Morin <[email protected]>
Date:   Wed Jul 22 21:46:56 2026 +0200

    Extraction gfc_copy_sequence_descriptor

Diff:
---
 gcc/fortran/trans-array.cc      | 18 +-----------------
 gcc/fortran/trans-descriptor.cc | 20 ++++++++++++++++++++
 gcc/fortran/trans-descriptor.h  |  2 ++
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 067458680af8..bf8f8b683a8f 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -9110,23 +9110,7 @@ gfc_conv_array_parameter (gfc_se *se, gfc_expr *expr, bool g77,
 	      && CLASS_DATA (fsym)->as->type == AS_EXPLICIT && !no_pack)
 	    {
 	      tree arr = gfc_create_var (TREE_TYPE (tmp), "parm");
-	      gfc_conv_descriptor_data_set (&block, arr,
-					    gfc_conv_descriptor_data_get (
-					      se->expr));
-	      gfc_conv_descriptor_lbound_set (&block, arr, gfc_index_zero_node,
-					      gfc_index_zero_node);
-	      gfc_conv_descriptor_ubound_set (
-		&block, arr, gfc_index_zero_node,
-		gfc_conv_descriptor_size (se->expr, expr->rank));
-	      gfc_conv_descriptor_stride_set (
-		&block, arr, gfc_index_zero_node,
-		gfc_conv_descriptor_stride_get (se->expr, gfc_index_zero_node));
-	      tree dtype_val = gfc_conv_descriptor_dtype_get (se->expr);
-	      gfc_conv_descriptor_dtype_set (&block, arr, dtype_val);
-	      gfc_conv_descriptor_rank_set (&block, arr, 1);
-	      gfc_conv_descriptor_span_set (&block, arr,
-					    gfc_conv_descriptor_span_get (arr));
-	      gfc_conv_descriptor_offset_set (&block, arr, gfc_index_zero_node);
+	      gfc_copy_sequence_descriptor (&block, arr, se->expr, expr->rank);
 	      se->expr = arr;
 	    }
 	  if (expr->rank == -1)
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 07deea2c1ba2..e60f61f243d9 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1307,3 +1307,23 @@ gfc_shift_descriptor (stmtblock_t *block, tree descr, int rank,
 
   gfc_conv_descriptor_offset_set (block, descr, offset);
 }
+ 
+
+void
+gfc_copy_sequence_descriptor (stmtblock_t *block, tree dest, tree src, int rank)
+{
+  gfc_conv_descriptor_data_set (block, dest,
+				gfc_conv_descriptor_data_get (src));
+  gfc_conv_descriptor_lbound_set (block, dest, gfc_index_zero_node,
+				  gfc_index_zero_node);
+  gfc_conv_descriptor_ubound_set (block, dest, gfc_index_zero_node,
+				  gfc_conv_descriptor_size (src, rank));
+  tree stride = gfc_conv_descriptor_stride_get (src, gfc_index_zero_node);
+  gfc_conv_descriptor_stride_set (block, dest, gfc_index_zero_node, stride);
+  gfc_conv_descriptor_dtype_set (block, dest,
+				 gfc_conv_descriptor_dtype_get (src));
+  gfc_conv_descriptor_rank_set (block, dest, 1);
+  gfc_conv_descriptor_span_set (block, dest,
+				gfc_conv_descriptor_span_get (src));
+  gfc_conv_descriptor_offset_set (block, dest, gfc_index_zero_node);
+}
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 9e99b91049a1..bd2c54f5c94c 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -92,6 +92,8 @@ void gfc_set_subarray_descriptor (stmtblock_t *, tree, tree, gfc_expr *, gfc_exp
 void gfc_shift_descriptor (stmtblock_t *, tree, int, tree [GFC_MAX_DIMENSIONS],
 			   tree [GFC_MAX_DIMENSIONS]);
 
+void gfc_copy_sequence_descriptor (stmtblock_t *, tree, tree, int);
+
 void gfc_set_descriptor_from_scalar_class (stmtblock_t *, tree, tree, gfc_expr *);
 void gfc_set_descriptor_from_scalar (stmtblock_t *, tree, tree, symbol_attribute,
 				     tree = NULL_TREE, tree = NULL_TREE);
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.