[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression deferred_type_component_3

Mikael Morin mikael@gcc.gnu.org
Fri Jun 13 15:10:56 GMT 2025


https://gcc.gnu.org/g:560a7e5d954f478d5c036bda56147d3ae0a72275

commit 560a7e5d954f478d5c036bda56147d3ae0a72275
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Fri May 30 22:16:46 2025 +0200

    Correction régression deferred_type_component_3

Diff:
---
 gcc/fortran/trans.cc | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc
index ed033a44a344..5eb993f29065 100644
--- a/gcc/fortran/trans.cc
+++ b/gcc/fortran/trans.cc
@@ -1879,8 +1879,12 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, tree errlen,
 			    omp_tmp, tmp);
 	}
       gfc_add_expr_to_block (&non_null, tmp);
-      gfc_add_modify (&non_null, pointer, build_int_cst (TREE_TYPE (pointer),
-							 0));
+      if (descr)
+	gfc_conv_descriptor_data_set (&non_null, descr,
+				      build_int_cst (ptr_type_node, 0));
+      else
+	gfc_add_modify (&non_null, pointer,
+			build_int_cst (TREE_TYPE (pointer), 0));
       if (flag_openmp_allocators && descr)
 	gfc_conv_descriptor_version_set (&non_null, descr, integer_zero_node);
 
@@ -1946,10 +1950,19 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, tree errlen,
       if (status != NULL_TREE && !integer_zerop (status))
 	{
 	  tree stat = build_fold_indirect_ref_loc (input_location, status);
-	  tree nullify = fold_build2_loc (input_location, MODIFY_EXPR,
-					  void_type_node, pointer,
-					  build_int_cst (TREE_TYPE (pointer),
-							 0));
+	  tree nullify;
+	  if (descr)
+	    {
+	      stmtblock_t blk;
+	      gfc_init_block (&blk);
+	      gfc_conv_descriptor_data_set (&blk, descr,
+					    build_int_cst (ptr_type_node, 0));
+	      nullify = gfc_finish_block (&blk);
+	    }
+	  else
+	    nullify = fold_build2_loc (input_location, MODIFY_EXPR,
+				       void_type_node, pointer,
+				       build_int_cst (TREE_TYPE (pointer), 0));
 
 	  TREE_USED (label_finish) = 1;
 	  tmp = build1_v (GOTO_EXPR, label_finish);
@@ -1960,6 +1973,9 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, tree errlen,
 				 tmp, nullify);
 	  gfc_add_expr_to_block (&non_null, tmp);
 	}
+      else if (descr)
+	gfc_conv_descriptor_data_set (&non_null, descr,
+				      build_int_cst (ptr_type_node, 0));
       else
 	gfc_add_modify (&non_null, pointer, build_int_cst (TREE_TYPE (pointer),
 							   0));


More information about the Gcc-cvs mailing list