https://gcc.gnu.org/g:3b34e8d35f2a13eb3887dbbb12a1107087c5971a

commit 3b34e8d35f2a13eb3887dbbb12a1107087c5971a
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Mon Sep 22 18:51:54 2025 +0200

    Correction régression coarray/class_1.f90

Diff:
---
 gcc/fortran/trans-array.cc | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 742a6cf15177..2c2183b9ebef 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3788,7 +3788,9 @@ enum gfc_array_ref_sort
      descriptor's span field.  */
   ARS_SPANNED_PTR_ARITH,
   /* Pointer arithmetics, using the CFI descriptor's sm fields.  */
-  ARS_CFI_PTR_ARITH
+  ARS_CFI_PTR_ARITH,
+  /* Not really an array ref.  */
+  ARS_SCALAR_COARRAY
 };
 
 
@@ -3796,6 +3798,9 @@ static gfc_array_ref_sort
 classify_array_ref (tree array, tree ref_base, gfc_expr *expr,
                    gfc_array_ref *ar, bool tmp_array)
 {
+  if (ar && ar->dimen == 0 && ar->codimen != 0)
+    return ARS_SCALAR_COARRAY;
+
   if (is_class_array_ref (ref_base, expr, nullptr))
     return ARS_CLASS_PTR_ARITH;
 
@@ -3820,7 +3825,6 @@ build_array_ref (gfc_se *se, tree array, tree ref_base, 
gfc_expr *expr,
 {
   switch (classify_array_ref (array, ref_base, expr, ar, is_temp_array))
     {
-
     case ARS_CLASS_PTR_ARITH:
       {
        bool success = build_class_array_ref (se, ref_base, expr, index);
@@ -3863,16 +3867,14 @@ build_array_ref (gfc_se *se, tree array, tree ref_base, 
gfc_expr *expr,
       }
       break;
 
-    case ARS_REGULAR_ARRAY_REF:
+
+    default:
       {
        bool non_negative_stride = is_temp_array
                                   || non_negative_strides_array_p (array);
        se->expr = gfc_build_array_ref (ref_base, index, non_negative_stride);
       }
       break;
-
-    default:
-      gcc_unreachable ();
     }
 }

Reply via email to