[gcc r17-2566] fortran: Use the setter to update the descriptor data field

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

commit r17-2566-g1961ef6412258898526629648b71fc5f21b3fa6d
Author: Mikael Morin <[email protected]>
Date:   Wed Jul 15 17:29:38 2026 +0200

    fortran: Use the setter to update the descriptor data field
    
    A MODIFY_EXPR was generated manually using the data reference returned by
    the getter.  Just use the setter instead.  Fixed in two different places.
    
    gcc/fortran/ChangeLog:
    
            * trans-expr.cc (gfc_conv_class_to_class): Use the data setter
            instead of generating a MODIFY_EXPR of the result of the data
            getter.
            * trans-intrinsic.cc (conv_intrinsic_move_alloc): Likewise.

Diff:
---
 gcc/fortran/trans-expr.cc      | 6 ++----
 gcc/fortran/trans-intrinsic.cc | 4 +---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index df029bfd1140..1083ea3fbbd2 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -1556,10 +1556,8 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts,
       else
 	{
 	  gfc_init_block (&block);
-
-	  tmp2 = gfc_conv_descriptor_data_get (gfc_class_data_get (var));
-	  gfc_add_modify (&block, tmp2, fold_convert (TREE_TYPE (tmp2),
-						      null_pointer_node));
+	  gfc_conv_descriptor_data_set (&block, gfc_class_data_get (var),
+					null_pointer_node);
 	  tmp2 = gfc_finish_block (&block);
 	}
 
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index bb0499ad7b3c..5e3681da4675 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -13599,9 +13599,7 @@ conv_intrinsic_move_alloc (gfc_code *code)
   gfc_add_modify_loc (input_location, &block, to_se.expr, from_se.expr);
 
   /* Set "from" to NULL.  */
-  tmp = gfc_conv_descriptor_data_get (from_se.expr);
-  gfc_add_modify_loc (input_location, &block, tmp,
-		      fold_convert (TREE_TYPE (tmp), null_pointer_node));
+  gfc_conv_descriptor_data_set (&block, from_se.expr, null_pointer_node);
 
   if (coarray && flag_coarray == GFC_FCOARRAY_LIB)
     {
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.