https://gcc.gnu.org/g:21d2c3018f76baf895ec5f14b08980d3c8fdf93f

commit 21d2c3018f76baf895ec5f14b08980d3c8fdf93f
Author: Mikael Morin <[email protected]>
Date:   Tue Oct 28 16:20:29 2025 +0100

    fortran: array descriptor: Move null factory function
    
    Move null descriptor factory function to a separate file.
    
    gcc/fortran/ChangeLog:
    
            * trans-array.cc (gfc_build_null_descriptor): Move function to ...
            * trans-descriptor.cc (gfc_build_null_descriptor): ... this file.
            * trans-array.h (gfc_build_null_descriptor): Move declaration to ...
            * trans-descriptor.h (gfc_build_null_descriptor): ... this file.

Diff:
---
 gcc/fortran/trans-array.cc      | 21 ---------------------
 gcc/fortran/trans-array.h       |  2 --
 gcc/fortran/trans-descriptor.cc | 24 ++++++++++++++++++++++++
 gcc/fortran/trans-descriptor.h  |  3 +++
 4 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 94e01dfc5e70..d40fbbc1d70a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -225,27 +225,6 @@ gfc_get_cfi_dim_sm (tree desc, tree idx)
 #define LBOUND_SUBFIELD 1
 #define UBOUND_SUBFIELD 2
 
-/* Build a null array descriptor constructor.  */
-
-tree
-gfc_build_null_descriptor (tree type)
-{
-  tree field;
-  tree tmp;
-
-  gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
-  gcc_assert (DATA_FIELD == 0);
-  field = TYPE_FIELDS (type);
-
-  /* Set a NULL data pointer.  */
-  tmp = build_constructor_single (type, field, null_pointer_node);
-  TREE_CONSTANT (tmp) = 1;
-  /* All other fields are ignored.  */
-
-  return tmp;
-}
-
-
 /* Modify a descriptor such that the lbound of a given dimension is the value
    specified.  This also updates ubound and offset accordingly.  */
 
diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h
index 83297bccb134..79bb49ee1d86 100644
--- a/gcc/fortran/trans-array.h
+++ b/gcc/fortran/trans-array.h
@@ -137,8 +137,6 @@ void gfc_conv_loop_setup (gfc_loopinfo *, locus *);
 void gfc_set_delta (gfc_loopinfo *);
 /* Resolve array assignment dependencies.  */
 void gfc_conv_resolve_dependencies (gfc_loopinfo *, gfc_ss *, gfc_ss *);
-/* Build a null array descriptor constructor.  */
-tree gfc_build_null_descriptor (tree);
 
 /* Get a single array element.  */
 void gfc_conv_array_ref (gfc_se *, gfc_array_ref *, gfc_expr *, locus *);
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 6b34bdb42210..b34dd64b874e 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -353,6 +353,30 @@ gfc_conv_descriptor_ubound_set (stmtblock_t *block, tree 
desc,
 }
 
 
+/* Array descriptor higher level routines.
+ 
******************************************************************************/
+
+/* Build a null array descriptor constructor.  */
+
+tree
+gfc_build_null_descriptor (tree type)
+{
+  tree field;
+  tree tmp;
+
+  gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
+  gcc_assert (DATA_FIELD == 0);
+  field = TYPE_FIELDS (type);
+
+  /* Set a NULL data pointer.  */
+  tmp = build_constructor_single (type, field, null_pointer_node);
+  TREE_CONSTANT (tmp) = 1;
+  /* All other fields are ignored.  */
+
+  return tmp;
+}
+
+
 /* Cleanup those #defines.  */
 
 #undef DATA_FIELD
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index dc7f08a8376b..ac2e058b2732 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -49,4 +49,7 @@ void gfc_conv_descriptor_lbound_set (stmtblock_t *block, tree 
desc, tree dim,
 void gfc_conv_descriptor_ubound_set (stmtblock_t *block, tree desc, tree dim,
                                     tree value);
 
+/* Build a null array descriptor constructor.  */
+tree gfc_build_null_descriptor (tree type);
+
 #endif /* GFC_TRANS_DESCRIPTOR_H */

Reply via email to