public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9356] Fortran: error recovery when simplifying MINLOC/MAXLOC
@ 2021-12-04 21:33 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2021-12-04 21:33 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3c1bcaa6224f79c6532dca28ebc7b466acbbc468
commit r11-9356-g3c1bcaa6224f79c6532dca28ebc7b466acbbc468
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon Nov 29 22:56:30 2021 +0100
Fortran: error recovery when simplifying MINLOC/MAXLOC
gcc/fortran/ChangeLog:
PR fortran/103473
* simplify.c (simplify_minmaxloc_nodim): Avoid NULL pointer
dereference when shape is not set.
gcc/testsuite/ChangeLog:
PR fortran/103473
* gfortran.dg/minmaxloc_15.f90: New test.
(cherry picked from commit 36421e76a7150621f2a5c7060ddd3f80aa825a40)
Diff:
---
gcc/fortran/simplify.c | 3 +++
gcc/testsuite/gfortran.dg/minmaxloc_15.f90 | 11 +++++++++++
2 files changed, 14 insertions(+)
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index ba0b3c4a362..77b982005fc 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -5280,6 +5280,9 @@ simplify_minmaxloc_nodim (gfc_expr *result, gfc_expr *extremum,
&& !mask->value.logical)
goto finish;
+ if (array->shape == NULL)
+ goto finish;
+
for (i = 0; i < array->rank; i++)
{
count[i] = 0;
diff --git a/gcc/testsuite/gfortran.dg/minmaxloc_15.f90 b/gcc/testsuite/gfortran.dg/minmaxloc_15.f90
new file mode 100644
index 00000000000..e4eba3501d5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/minmaxloc_15.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/103473 - ICE in simplify_minmaxloc_nodim
+! Test case by Gerhard Steinmetz.
+
+subroutine s
+ implicit none
+ integer, parameter :: a(+'1') = [1] ! { dg-error "unary numeric operator" }
+ print *, minloc (a)
+end
+
+! { dg-prune-output "Parameter array" }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-04 21:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-04 21:33 [gcc r11-9356] Fortran: error recovery when simplifying MINLOC/MAXLOC 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).