[gcc(refs/users/mikael/heads/refactor_descriptor_v203.05)] Correction pr85938

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

commit 8d0bca5baf8eb01af60306432892f5478f515eff
Author: Mikael Morin <[email protected]>
Date:   Tue Jul 14 20:23:17 2026 +0200

    Correction pr85938

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

diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc
index 7418b811a72b..5b6b053c7930 100644
--- a/gcc/fortran/trans.cc
+++ b/gcc/fortran/trans.cc
@@ -1834,16 +1834,23 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, tree errlen,
 	    {
 	      token = caf_token;
 	      if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer)))
-		pointer = gfc_conv_descriptor_data_get (pointer);
+		{
+		  descr = pointer;
+		  pointer = gfc_conv_descriptor_data_get (descr);
+		}
 	    }
 	  else
 	    {
-	      tree caf_type, caf_decl = pointer;
+	      tree caf_type;
+	      tree caf_decl = pointer;
 	      pointer = gfc_conv_descriptor_data_get (caf_decl);
 	      caf_type = TREE_TYPE (caf_decl);
 	      STRIP_NOPS (pointer);
 	      if (GFC_DESCRIPTOR_TYPE_P (caf_type))
-		token = gfc_conv_descriptor_token (caf_decl);
+		{
+		  descr = caf_decl;
+		  token = gfc_conv_descriptor_token (caf_decl);
+		}
 	      else if (DECL_LANG_SPECIFIC (caf_decl)
 		       && GFC_DECL_TOKEN (caf_decl) != NULL_TREE)
 		token = GFC_DECL_TOKEN (caf_decl);
@@ -1869,7 +1876,10 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, tree errlen,
 	}
       else if (flag_coarray == GFC_FCOARRAY_SINGLE
 	       && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer)))
-	pointer = gfc_conv_descriptor_data_get (pointer);
+	{
+	  descr = pointer;
+	  pointer = gfc_conv_descriptor_data_get (descr);
+	}
     }
   else if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer)))
     {
@@ -1943,8 +1953,11 @@ 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 != nullptr)
+	gfc_conv_descriptor_data_set (&non_null, descr, null_pointer_node);
+      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);
 
@@ -2024,6 +2037,8 @@ 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 != nullptr)
+	gfc_conv_descriptor_data_set (&non_null, descr, null_pointer_node);
       else
 	gfc_add_modify (&non_null, pointer, build_int_cst (TREE_TYPE (pointer),
 							   0));
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.