[gcc(refs/users/mikael/heads/refactor_descriptor_v203.04)] Correction char4_dest-2

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

commit 75e8f16c5fad92f70520993836be3a34a134f552
Author: Mikael Morin <[email protected]>
Date:   Wed Jul 15 20:00:40 2026 +0200

    Correction char4_dest-2

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

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 8e71ae3b51df..9e881c7db826 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -12838,16 +12838,22 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t *block,
 				 builtin_decl_explicit (BUILT_IN_CALLOC),
 				 2, build_one_cst (size_type_node),
 				 size_in_bytes);
-      tmp = fold_convert (TREE_TYPE (lse.expr), tmp);
-      gfc_add_modify (block, lse.expr, tmp);
+      tree dest = lse.expr;
+      if (TREE_CODE (dest) == NOP_EXPR)
+	dest = TREE_OPERAND (dest, 0);
+      tmp = fold_convert (TREE_TYPE (dest), tmp);
+      gfc_add_modify (block, dest, tmp);
     }
   else
     {
       tmp = build_call_expr_loc (input_location,
 				 builtin_decl_explicit (BUILT_IN_MALLOC),
 				 1, size_in_bytes);
-      tmp = fold_convert (TREE_TYPE (lse.expr), tmp);
-      gfc_add_modify (block, lse.expr, tmp);
+      tree dest = lse.expr;
+      if (TREE_CODE (dest) == NOP_EXPR)
+	dest = TREE_OPERAND (dest, 0);
+      tmp = fold_convert (TREE_TYPE (dest), tmp);
+      gfc_add_modify (block, dest, tmp);
     }
 
   if (expr1->ts.type == BT_CHARACTER && expr1->ts.deferred)
@@ -12894,8 +12900,11 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t *block,
 	  tmp = build3_loc (input_location, COND_EXPR, TREE_TYPE (tmp),
 			    omp_cond, omp_tmp, tmp);
 	}
-      tmp = fold_convert (TREE_TYPE (lse.expr), tmp);
-      gfc_add_modify (block, lse.expr, tmp);
+      tree dest = lse.expr;
+      if (TREE_CODE (dest) == NOP_EXPR)
+	dest = TREE_OPERAND (dest, 0);
+      tmp = fold_convert (TREE_TYPE (dest), tmp);
+      gfc_add_modify (block, dest, tmp);
       if (omp_cond)
 	gfc_add_expr_to_block (block,
 			       build3_loc (input_location, COND_EXPR,
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.