public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2747] Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986]
@ 2022-09-20 20:50 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-09-20 20:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5976fbf9d5dd9542fcb82eebb2185886fd52d000

commit r13-2747-g5976fbf9d5dd9542fcb82eebb2185886fd52d000
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 20 22:41:48 2022 +0200

    Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986]
    
    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.

Diff:
---
 gcc/fortran/simplify.cc                | 1 +
 gcc/testsuite/gfortran.dg/pr106986.f90 | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 140c17721a7..c0fbd0ed7c2 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -5895,6 +5895,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
index 00000000000..a309b25d181
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106986.f90
@@ -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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-20 20:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20 20:50 [gcc r13-2747] Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986] Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).