]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: array descriptor: Move null factory function [PR122521]
authorMikael Morin <mikael@gcc.gnu.org>
Thu, 2 Jul 2026 08:44:25 +0000 (10:44 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Thu, 2 Jul 2026 08:44:25 +0000 (10:44 +0200)
Move null descriptor factory function to trans-descriptor.cc.

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-array.cc (DATA_FIELD, OFFSET_FIELD, DTYPE_FIELD, SPAN_FIELD,
DIMENSION_FIELD, CAF_TOKEN_FIELD, STRIDE_SUBFIELD, LBOUND_SUBFIELD,
UBOUND_SUBFIELD): Remove preprocessor constants.
(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.

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

index 2aaf89b6257b5703431e88d80e56d4b1a095a57d..f45d2e5117997c6afced9b3581947ff351499d41 100644 (file)
@@ -216,38 +216,6 @@ gfc_get_cfi_dim_sm (tree desc, tree idx)
 #undef CFI_DIM_FIELD_SM
 
 
-#define DATA_FIELD 0
-#define OFFSET_FIELD 1
-#define DTYPE_FIELD 2
-#define SPAN_FIELD 3
-#define DIMENSION_FIELD 4
-#define CAF_TOKEN_FIELD 5
-
-#define STRIDE_SUBFIELD 0
-#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.  */
 
@@ -285,19 +253,6 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* block, tree desc,
 }
 
 
-/* Cleanup those #defines.  */
-
-#undef DATA_FIELD
-#undef OFFSET_FIELD
-#undef DTYPE_FIELD
-#undef SPAN_FIELD
-#undef DIMENSION_FIELD
-#undef CAF_TOKEN_FIELD
-#undef STRIDE_SUBFIELD
-#undef LBOUND_SUBFIELD
-#undef UBOUND_SUBFIELD
-
-
 /* Mark a SS chain as used.  Flags specifies in which loops the SS is used.
    flags & 1 = Main loop body.
    flags & 2 = temp copy loop.  */
index 721364fb6acfa90a9258a6d607c7c52c38b3fef1..e831d22c7bc077bf246dd3867b252d2cca58f3f8 100644 (file)
@@ -138,8 +138,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 *);
index 18603601663f1c6676beb311267adbbad860a84e..75fb9206ae95205b10fe22cc9b59380cfe154f26 100644 (file)
@@ -379,6 +379,30 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
 }
 
 
+/* 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
index db877ee402b62577771f37c2c693d72f9fb4114e..44c8f6f1215dd05f439f345f6380c8028554a3f0 100644 (file)
@@ -51,4 +51,7 @@ void gfc_get_descriptor_offsets_for_info (const_tree, tree *, tree *, tree *,
                                          tree *, tree *, tree *, tree *,
                                          tree *);
 
+/* Build a null array descriptor constructor.  */
+tree gfc_build_null_descriptor (tree type);
+
 #endif /* GFC_TRANS_DESCRIPTOR_H */