https://gcc.gnu.org/g:914b7296ebe4940abc23be419a946e491402ed67

commit r16-3017-g914b7296ebe4940abc23be419a946e491402ed67
Author: Mikael Morin <morin-mik...@orange.fr>
Date:   Tue Aug 5 14:57:59 2025 +0200

    fortran: Remove redundant initialisation of associate variable span
    
    In the initialization of associate variable array descriptors, remove
    an overwrite of the span field.  The descriptor that is returned by
    gfc_conv_expr_descriptor should already be usable without it.
    
    The range of cases where the code was in effect is not completely
    clear.  The span overwrite looks redundant, and the conditional guarding
    it seems to make it dead.  However, the conditions governing
    gfc_conv_expr_descriptor, gfc_get_array_span and trans_associate_var
    make it difficult to track what is possible and what isn't.  Trying to
    investigate the case where the target is an array subreference wrapped
    in parenthesis, I encountered a wrong-code issue, PR121384.  Let's
    remove all this and see what happens.
    
    gcc/fortran/ChangeLog:
    
            * trans-stmt.cc (trans_associate_var): Remove overwrite of the
            span field of the associate variable's array descriptor.

Diff:
---
 gcc/fortran/trans-stmt.cc | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 198acee1ba3e..5974e4011bdd 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -2182,16 +2182,6 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block 
*block)
                                              dim, gfc_index_one_node);
        }
 
-      /* If this is a subreference array pointer associate name use the
-        associate variable element size for the value of 'span'.  */
-      if (sym->attr.subref_array_pointer && !se.direct_byref)
-       {
-         gcc_assert (e->expr_type == EXPR_VARIABLE);
-         tmp = gfc_get_array_span (se.expr, e);
-
-         gfc_conv_descriptor_span_set (&se.pre, desc, tmp);
-       }
-
       if (e->expr_type == EXPR_FUNCTION
          && sym->ts.type == BT_DERIVED
          && sym->ts.u.derived

Reply via email to