[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression realloc_on_assign_23.f90

Mikael Morin mikael@gcc.gnu.org
Fri Jun 13 14:46:12 GMT 2025


https://gcc.gnu.org/g:0514e55671c77ce55cb45149cdf3d4c4c34a0d6a

commit 0514e55671c77ce55cb45149cdf3d4c4c34a0d6a
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Mon Feb 17 21:28:01 2025 +0100

    Correction régression realloc_on_assign_23.f90

Diff:
---
 gcc/fortran/trans-expr.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index c01f7352a784..6673b554e7f5 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -12613,6 +12613,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
       rhs_caf_attr = gfc_caf_attr (expr2, false, &rhs_refs_comp);
     }
 
+  tree reallocation = NULL_TREE;
   if (lss != gfc_ss_terminator)
     {
       /* The assignment needs scalarization.  */
@@ -12686,9 +12687,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
 	{
 	  realloc_lhs_warning (expr1->ts.type, true, &expr1->where);
 	  ompws_flags &= ~OMPWS_SCALARIZER_WS;
-	  tmp = gfc_alloc_allocatable_for_assignment (&loop, expr1, expr2);
-	  if (tmp != NULL_TREE)
-	    gfc_add_expr_to_block (&loop.pre, tmp);
+	  reallocation = gfc_alloc_allocatable_for_assignment (&loop, expr1, expr2);
 	}
 
       for (gfc_ss *s = loop.ss; s != gfc_ss_terminator; s = s->loop_chain)
@@ -13021,6 +13020,9 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
       if (maybe_workshare)
 	ompws_flags &= ~OMPWS_SCALARIZER_BODY;
 
+      if (reallocation != NULL_TREE)
+	gfc_add_expr_to_block (&loop.code[loop.dimen - 1], reallocation);
+
       /* Generate the copying loops.  */
       gfc_trans_scalarizing_loops (&loop, &body);


More information about the Gcc-cvs mailing list