Fortran: ICE in gfc_compare_array_spec [PR108528]
authorSteve Kargl <kargl@gcc.gnu.org>
Wed, 25 Jan 2023 19:38:43 +0000 (20:38 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Wed, 25 Jan 2023 19:44:40 +0000 (20:44 +0100)
gcc/fortran/ChangeLog:

PR fortran/108528
* array.cc (compare_bounds): Return false instead of generating an
internal error on an invalid argument type.

gcc/testsuite/ChangeLog:

PR fortran/108528
* gfortran.dg/pr108528.f90: New test.

gcc/fortran/array.cc
gcc/testsuite/gfortran.dg/pr108528.f90 [new file with mode: 0644]

index e8a2c32..be5eb8b 100644 (file)
@@ -967,7 +967,7 @@ gfc_copy_array_spec (gfc_array_spec *src)
 
 
 /* Returns nonzero if the two expressions are equal.
-   We should not need to support more than constant values, as thats what is
+   We should not need to support more than constant values, as that's what is
    allowed in derived type component array spec.  However, we may create types
    with non-constant array spec for dummy variable class container types, for
    which the _data component holds the array spec of the variable declaration.
@@ -979,7 +979,7 @@ compare_bounds (gfc_expr *bound1, gfc_expr *bound2)
   if (bound1 == NULL || bound2 == NULL
       || bound1->ts.type != BT_INTEGER
       || bound2->ts.type != BT_INTEGER)
-    gfc_internal_error ("gfc_compare_array_spec(): Array spec clobbered");
+    return false;
 
   /* What qualifies as identical bounds?  We could probably just check that the
      expressions are exact clones.  We avoid rewriting a specific comparison
diff --git a/gcc/testsuite/gfortran.dg/pr108528.f90 b/gcc/testsuite/gfortran.dg/pr108528.f90
new file mode 100644 (file)
index 0000000..7a353cb
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/108528 -
+! Contributed by G.Steinmetz
+
+function f()         ! { dg-error "mismatched array specifications" }
+  integer :: f((2.)) ! { dg-error "must be of INTEGER type" }
+  integer :: g((2))
+entry g()
+end