https://gcc.gnu.org/g:8d221cc9014156f560b118a74e82bcf6feef0b29

commit 8d221cc9014156f560b118a74e82bcf6feef0b29
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Mon Aug 11 21:52:36 2025 +0200

    Refactoring descriptor_write

Diff:
---
 gcc/fortran/trans-descriptor.cc | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 50237fa66bef..d928241d10b6 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -721,6 +721,15 @@ gfc_get_dtype_rank_type (int rank, tree etype)
 }
 
 
+enum descriptor_write_case
+{
+  POINTER_NULLIFY,
+  RESULT_INIT,
+  ABSENT_ARG_INIT,
+  STATIC_INIT
+};
+
+
 class constructor_elements
 {
   vec<constructor_elt, va_gc> *values;
@@ -753,22 +762,22 @@ constructor_elements::build (tree type)
 }
 
 
-struct write_destination
+struct descriptor_write
 {
-  enum write_type
+  const enum write_type
   {
     STATIC_INIT,
     REGULAR_ASSIGN
   }
   type;
 
-  tree ref;
+  const tree ref;
 
   union u
   {
     struct rw
     {
-      stmtblock_t *block;
+      stmtblock_t * const block;
 
       rw (stmtblock_t *b) : block(b) {}
     }
@@ -781,16 +790,16 @@ struct write_destination
   }
   u;
 
-  write_destination (tree r, stmtblock_t *b)
+  descriptor_write (tree r, stmtblock_t *b)
       : type (REGULAR_ASSIGN), ref (r), u (b) {}
-  write_destination (tree d) : type (STATIC_INIT), ref (d), u () {}
+  descriptor_write (tree d) : type (STATIC_INIT), ref (d), u () {}
 };
 
 
 static void
-set_descriptor_field (write_destination &dest, descriptor_field field, tree 
value)
+set_descriptor_field (descriptor_write &dest, descriptor_field field, tree 
value)
 {
-  if (dest.type == write_destination::STATIC_INIT)
+  if (dest.type == descriptor_write::STATIC_INIT)
     {
       tree field_decl = gfc_advance_chain (TYPE_FIELDS (TREE_TYPE (dest.ref)),
                                           field);
@@ -805,10 +814,10 @@ set_descriptor_field (write_destination &dest, 
descriptor_field field, tree valu
 
 
 static void
-set_descriptor (write_destination &dest)
+set_descriptor (descriptor_write &dest)
 {
   set_descriptor_field (dest, DATA_FIELD, null_pointer_node);
-  if (dest.type == write_destination::STATIC_INIT)
+  if (dest.type == descriptor_write::STATIC_INIT)
     {
       tree decl = dest.ref;
       tree type = TREE_TYPE (decl);
@@ -925,7 +934,7 @@ gfc_conv_descriptor_cosize (tree desc, int rank, int corank)
 void
 gfc_nullify_descriptor (stmtblock_t *block, tree descr)
 {
-  write_destination dest(descr, block);
+  descriptor_write dest(descr, block);
   set_descriptor (dest);
 }

Reply via email to