]> gcc.gnu.org Git - gcc.git/commitdiff
Fortran: improve error recovery while simplifying size of bad array [PR103694]
authorHarald Anlauf <anlauf@gmx.de>
Tue, 23 Aug 2022 20:16:14 +0000 (22:16 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Fri, 26 Aug 2022 20:03:21 +0000 (22:03 +0200)
gcc/fortran/ChangeLog:

PR fortran/103694
* simplify.cc (simplify_size): The size expression of an array cannot
be simplified if an error occurs while resolving the array spec.

gcc/testsuite/ChangeLog:

PR fortran/103694
* gfortran.dg/pr103694.f90: New test.

(cherry picked from commit 55d8c5409325001c89c35c3d04d425dec9127146)

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

index 2f4f13b6a830a00417c1b5529bf8b6c94b5cedf6..1d74cf35a25d90e55a54f00e8e57a9927f7dec70 100644 (file)
@@ -7498,8 +7498,9 @@ simplify_size (gfc_expr *array, gfc_expr *dim, int k)
     }
 
   for (ref = array->ref; ref; ref = ref->next)
-    if (ref->type == REF_ARRAY && ref->u.ar.as)
-      gfc_resolve_array_spec (ref->u.ar.as, 0);
+    if (ref->type == REF_ARRAY && ref->u.ar.as
+       && !gfc_resolve_array_spec (ref->u.ar.as, 0))
+      return NULL;
 
   if (dim == NULL)
     {
diff --git a/gcc/testsuite/gfortran.dg/pr103694.f90 b/gcc/testsuite/gfortran.dg/pr103694.f90
new file mode 100644 (file)
index 0000000..3ed8b20
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/103694 - ICE in gfc_conv_expr_op
+! Contributed by G.Steinmetz
+
+subroutine s
+  type t
+     integer :: a(2)
+  end type
+  type(t) :: x((0.)/0)
+  integer :: n = size(x(1)%a) ! { dg-error "does not reduce to a constant expression" }
+end
This page took 0.077139 seconds and 5 git commands to generate.