]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986]
authorHarald Anlauf <anlauf@gmx.de>
Tue, 20 Sep 2022 20:41:48 +0000 (22:41 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Thu, 22 Sep 2022 18:43:50 +0000 (20:43 +0200)
gcc/fortran/ChangeLog:

PR fortran/106986
* simplify.cc (gfc_simplify_findloc): Do not try to simplify
intrinsic FINDLOC when the ARRAY argument has a NULL shape.

gcc/testsuite/ChangeLog:

PR fortran/106986
* gfortran.dg/pr106986.f90: New test.

(cherry picked from commit 5976fbf9d5dd9542fcb82eebb2185886fd52d000)

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

index 0eff5a546cc309152280b350600ea630780ed536..a6a3e94fbd9fcfa73a123a832e0029219b41c3b4 100644 (file)
@@ -5857,6 +5857,7 @@ gfc_simplify_findloc (gfc_expr *array, gfc_expr *value, gfc_expr *dim,
   bool back_val = false;
 
   if (!is_constant_array_expr (array)
+      || array->shape == NULL
       || !gfc_is_constant_expr (dim))
     return NULL;
 
diff --git a/gcc/testsuite/gfortran.dg/pr106986.f90 b/gcc/testsuite/gfortran.dg/pr106986.f90
new file mode 100644 (file)
index 0000000..a309b25
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/106986 - ICE in simplify_findloc_nodim
+! Contributed by G.Steinmetz
+
+program p
+  integer, parameter :: a(:) = [1] ! { dg-error "deferred shape" }
+  print *, findloc (a, 1)
+end