https://gcc.gnu.org/g:612f8e4f7a77e1128924e6fafe0e12a363fc631b

commit 612f8e4f7a77e1128924e6fafe0e12a363fc631b
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Jan 10 19:03:04 2025 +0100

    Correction régression dummy_3

Diff:
---
 gcc/fortran/trans-expr.cc | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 14f92e7575dc..77e8a55af457 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -919,8 +919,17 @@ gfc_class_array_data_assign (stmtblock_t *block, tree 
lhs_desc, tree rhs_desc,
     type = TREE_TYPE (tmp);
   else
     {
-      gcc_assert (TREE_TYPE (tmp) == TREE_TYPE (tmp2));
-      type = TREE_TYPE (tmp);
+      int corank = GFC_TYPE_ARRAY_CORANK (TREE_TYPE (lhs_desc));
+      int corank2 = GFC_TYPE_ARRAY_CORANK (TREE_TYPE (rhs_desc));
+      if (corank > 0 && corank2 == 0)
+       type = TREE_TYPE (tmp2);
+      else if (corank2 > 0 && corank == 0)
+       type = TREE_TYPE (tmp);
+      else
+       {
+         gcc_assert (TREE_TYPE (tmp) == TREE_TYPE (tmp2));
+         type = TREE_TYPE (tmp);
+       }
     }
 
   tmp = build4_loc (input_location, ARRAY_RANGE_REF, type, tmp,

Reply via email to