https://gcc.gnu.org/g:03aa3637ece2639462c321efd53ac454d4f97d04

commit 03aa3637ece2639462c321efd53ac454d4f97d04
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 aa79dd82ead6..9c1d4b763b7a 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -1468,7 +1468,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