[gcc(refs/users/mikael/heads/refactor_descriptor_v206.01)] fortran: array descriptor: Move dtype layout constants out of header [PR122521]

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

commit e4eea36b512bbb6e2a89b5896b44f81492aabbaf
Author: Mikael Morin <[email protected]>
Date:   Fri Jul 24 12:25:28 2026 +0200

    fortran: array descriptor: Move dtype layout constants out of header [PR122521]
    
    Fortran-tested on aarch64-unknown-linux-gnu.  OK for mainline?
    
    -- >8 --
    
    The file trans.h contains preprocessor constants describing the ordering of
    the dtype subfields of array descriptors.  The functions using them have
    been moved to trans-descriptor.cc; now move the constants themselves.
    
            PR fortran/122521
    
    gcc/fortran/ChangeLog:
    
            * trans.h (GFC_DTYPE_ELEM_LEN, GFC_DTYPE_VERSION, GFC_DTYPE_RANK,
            GFC_DTYPE_TYPE, GFC_DTYPE_ATTRIBUTE): Move preprocessor constants...
            * trans-descriptor.cc (GFC_DTYPE_ELEM_LEN, GFC_DTYPE_VERSION,
            GFC_DTYPE_RANK, GFC_DTYPE_TYPE, GFC_DTYPE_ATTRIBUTE): ... here.
            Undefine the constants after the last function using them.

Diff:
---
 gcc/fortran/trans-descriptor.cc | 13 +++++++++++++
 gcc/fortran/trans.h             |  6 ------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index e20159fa3c66..5a92cbba4da1 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -61,6 +61,12 @@ along with GCC; see the file COPYING3.  If not see
 #define LBOUND_SUBFIELD 1
 #define UBOUND_SUBFIELD 2
 
+#define GFC_DTYPE_ELEM_LEN 0
+#define GFC_DTYPE_VERSION 1
+#define GFC_DTYPE_RANK 2
+#define GFC_DTYPE_TYPE 3
+#define GFC_DTYPE_ATTRIBUTE 4
+
 
 /* Get FIELD_IDX'th field in struct TYPE.  */
 
@@ -697,10 +703,17 @@ gfc_build_null_descriptor (tree type)
 #undef SPAN_FIELD
 #undef DIMENSION_FIELD
 #undef CAF_TOKEN_FIELD
+
 #undef STRIDE_SUBFIELD
 #undef LBOUND_SUBFIELD
 #undef UBOUND_SUBFIELD
 
+#undef GFC_DTYPE_ELEM_LEN
+#undef GFC_DTYPE_VERSION
+#undef GFC_DTYPE_RANK
+#undef GFC_DTYPE_TYPE
+#undef GFC_DTYPE_ATTRIBUTE
+
 
 /* For an array descriptor, get the total number of elements.  This is just
    the product of the extents along from_dim to to_dim.  */
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 0bdee5820fdd..ca766e0a3394 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -1016,12 +1016,6 @@ extern GTY(()) tree gfor_fndecl_cfi_deep_copy_array;
 /* gfortran-specific declaration information, the _CONT versions denote
    arrays with CONTIGUOUS attribute.  */
 
-#define GFC_DTYPE_ELEM_LEN 0
-#define GFC_DTYPE_VERSION 1
-#define GFC_DTYPE_RANK 2
-#define GFC_DTYPE_TYPE 3
-#define GFC_DTYPE_ATTRIBUTE 4
-
 enum gfc_array_kind
 {
   GFC_ARRAY_UNKNOWN,
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.