[PATCH 1/6] fortran: array descriptor: Move nullification code [PR122521]
Mikael Morin <[email protected]> Sun, 2 Aug 2026 22:59:34 +0200
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <[email protected]> |
From: Mikael Morin <[email protected]> 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. --- 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 5a92cbba4da..53715b65e60 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 7a206e2a4b2..cc15ac392a3 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 33b7838f74a..53cda9cc59a 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) { -- 2.53.0