[gcc(refs/users/mikael/heads/refactor_descriptor_v206.01)] fortran: array descriptor: Move nullification code [PR122521]

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

commit e0bac505ed892efdb2a19fe66d7d01c4ef7b86c1
Author: Mikael Morin <[email protected]>
Date:   Wed Jul 29 16:37:07 2026 +0200

    fortran: array descriptor: Move nullification code [PR122521]
    
    Fortran-tested on aarch64-unknown-linux-gnu.  OK for mainline?
    
    -- >8 --
    
    Move the pointer nullification implementing code to its own function in
    trans-descriptor.cc.
    
            PR fortran/122521
    
    gcc/fortran/ChangeLog:
    
            * trans-expr.cc (gfc_trans_pointer_assignment): Move pointer
            nullification generation ...
            * trans-descriptor.cc (gfc_nullify_descriptor): ... here as a new
            function.
            * trans-descriptor.h (gfc_nullify_descriptor): New declaration.

Diff:
---
 gcc/fortran/trans-descriptor.cc | 10 ++++++++++
 gcc/fortran/trans-descriptor.h  |  2 ++
 gcc/fortran/trans-expr.cc       |  2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 5a92cbba4da1..53715b65e600 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -715,6 +715,16 @@ gfc_build_null_descriptor (tree type)
 #undef GFC_DTYPE_ATTRIBUTE
 
 
+/* Add code to BLOCK implementing the pointer assigment from NULL() to the
+   pointer represented by the array descriptor DESCR.  */
+
+void
+gfc_nullify_descriptor (stmtblock_t *block, tree descr)
+{
+  gfc_conv_descriptor_data_set (block, descr, null_pointer_node);
+}
+
+
 /* 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-descriptor.h b/gcc/fortran/trans-descriptor.h
index 7a206e2a4b21..cc15ac392a34 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -63,6 +63,8 @@ void gfc_get_descriptor_offsets_for_info (const_tree, tree *, tree *, tree *,
 /* Build a null array descriptor constructor.  */
 tree gfc_build_null_descriptor (tree type);
 
+void gfc_nullify_descriptor (stmtblock_t *block, tree);
+
 tree gfc_conv_descriptor_size (tree, int);
 tree gfc_conv_descriptor_cosize (tree, int, int);
 
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 33b7838f74ac..53cda9cc59aa 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -11374,7 +11374,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
       if (expr2->expr_type == EXPR_NULL)
 	{
 	  /* Just set the data pointer to null.  */
-	  gfc_conv_descriptor_data_set (&lse.pre, lse.expr, null_pointer_node);
+	  gfc_nullify_descriptor (&lse.pre, lse.expr);
 	}
       else if (rank_remap)
 	{
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.