]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: array descriptor: Move array growth function [PR122521]
authorMikael Morin <mikael@gcc.gnu.org>
Thu, 2 Jul 2026 08:45:09 +0000 (10:45 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Thu, 2 Jul 2026 08:45:09 +0000 (10:45 +0200)
Move gfc_grow_array, a descriptor growth function used in array constructor
descriptors initialisation, to trans-descriptor.cc.

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_grow_array): Move function ...
* trans-descriptor.cc (gfc_grow_array): ... to this file.
* trans-descriptor.h (gfc_grow_array): Add declaration.

gcc/fortran/trans-array.cc
gcc/fortran/trans-descriptor.cc
gcc/fortran/trans-descriptor.h

index 876d8d9f9bdb2fb3a03a007ed618cc36547fc063..f2b03b42efbb9cb036a7f054438536e4ccbcb8b9 100644 (file)
@@ -1409,43 +1409,6 @@ gfc_get_iteration_count (tree start, tree end, tree step)
 }
 
 
-/* Extend the data in array DESC by EXTRA elements.  */
-
-static void
-gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra)
-{
-  tree arg0, arg1;
-  tree tmp;
-  tree size;
-  tree ubound;
-
-  if (integer_zerop (extra))
-    return;
-
-  ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[0]);
-
-  /* Add EXTRA to the upper bound.  */
-  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-                        ubound, extra);
-  gfc_conv_descriptor_ubound_set (pblock, desc, gfc_rank_cst[0], tmp);
-
-  /* Get the value of the current data pointer.  */
-  arg0 = gfc_conv_descriptor_data_get (desc);
-
-  /* Calculate the new array size.  */
-  size = TYPE_SIZE_UNIT (gfc_get_element_type (TREE_TYPE (desc)));
-  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-                        ubound, gfc_index_one_node);
-  arg1 = fold_build2_loc (input_location, MULT_EXPR, size_type_node,
-                         fold_convert (size_type_node, tmp),
-                         fold_convert (size_type_node, size));
-
-  /* Call the realloc() function.  */
-  tmp = gfc_call_realloc (pblock, arg0, arg1);
-  gfc_conv_descriptor_data_set (pblock, desc, tmp);
-}
-
-
 /* Return true if the bounds of iterator I can only be determined
    at run time.  */
 
index eff9108ef987272baab98f14870afaa924786fcd..fe2fe00599298c105420d7e2eeda72e02d5ca612 100644 (file)
@@ -541,3 +541,40 @@ gfc_copy_descriptor (stmtblock_t *block, tree dst, tree src, int rank)
 
   gfc_conv_descriptor_offset_set (block, dst, offset);
 }
+
+
+/* Extend the data in array DESC by EXTRA elements.  */
+
+void
+gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra)
+{
+  tree arg0, arg1;
+  tree tmp;
+  tree size;
+  tree ubound;
+
+  if (integer_zerop (extra))
+    return;
+
+  ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[0]);
+
+  /* Add EXTRA to the upper bound.  */
+  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+                        ubound, extra);
+  gfc_conv_descriptor_ubound_set (pblock, desc, gfc_rank_cst[0], tmp);
+
+  /* Get the value of the current data pointer.  */
+  arg0 = gfc_conv_descriptor_data_get (desc);
+
+  /* Calculate the new array size.  */
+  size = TYPE_SIZE_UNIT (gfc_get_element_type (TREE_TYPE (desc)));
+  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+                        ubound, gfc_index_one_node);
+  arg1 = fold_build2_loc (input_location, MULT_EXPR, size_type_node,
+                         fold_convert (size_type_node, tmp),
+                         fold_convert (size_type_node, size));
+
+  /* Call the realloc() function.  */
+  tmp = gfc_call_realloc (pblock, arg0, arg1);
+  gfc_conv_descriptor_data_set (pblock, desc, tmp);
+}
index b1623a2180331f89d5d2f1c46b2c635c3e6e67a0..816973825b6558d3540753dab4a6b7c0b4918e06 100644 (file)
@@ -62,4 +62,6 @@ void gfc_conv_shift_descriptor_lbound (stmtblock_t*, tree, int, tree);
 
 void gfc_copy_descriptor (stmtblock_t *, tree, tree, int);
 
+void gfc_grow_array (stmtblock_t *, tree, tree);
+
 #endif /* GFC_TRANS_DESCRIPTOR_H */