https://gcc.gnu.org/g:fe7cd1f179eda21577779f9309e37e8bf345b2ab

commit fe7cd1f179eda21577779f9309e37e8bf345b2ab
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Apr 11 17:18:48 2025 +0200

    Correction ICE ISO_Fortran_binding_5

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

diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 5e647d2965e5..b02215f6620d 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -1465,7 +1465,14 @@ gfc_get_element_type (tree type)
 
       /* For arrays, which are not scalar coarrays.  */
       if (TREE_CODE (element) == ARRAY_TYPE && !TYPE_STRING_FLAG (element))
-       element = TREE_TYPE (element);
+       {
+         int rank = GFC_TYPE_ARRAY_RANK (type);
+         for (int i = 0; i < rank; i++)
+           {
+             gcc_assert (TREE_CODE (element) == ARRAY_TYPE);
+             element = TREE_TYPE (element);
+           }
+       }
     }
 
   return element;

Reply via email to