https://gcc.gnu.org/g:1460afb87f0802a563c3ea8759dd38d331775750

commit 1460afb87f0802a563c3ea8759dd38d331775750
Author: Mikael Morin <[email protected]>
Date:   Sun Sep 20 16:38:58 2026 +0200

    Essai correction régression class_allocate_22

Diff:
---
 gcc/fortran/trans-stmt.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 739a62a798e2..93642d9db168 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -6797,6 +6797,8 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist 
*omp_allocate)
                                     code->expr3->ts,
                                     false, true,
                                     false, false);
+         if (POINTER_TYPE_P (TREE_TYPE (se.expr)))
+           se.expr = build_fold_indirect_ref_loc (input_location, se.expr);
          temp_obj_created = temp_var_needed = !VAR_P (se.expr);
        }
       gfc_add_block_to_block (&block, &se.pre);
@@ -6810,6 +6812,12 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist 
*omp_allocate)
 
       if (se.class_container)
        source_class = se.class_container;
+      if (GFC_CLASS_TYPE_P (TREE_TYPE (se.expr)))
+       {
+         if (source_class == NULL_TREE)
+           source_class = se.expr;
+         se.expr = gfc_class_data_get (se.expr);
+       }
 
       /* Special case when string in expr3 is scalar and has length zero.  */
       if (code->expr3->ts.type == BT_CHARACTER

Reply via email to