public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10281] Fortran: improve error recovery while simplifying size of bad array [PR103694]
@ 2022-09-30 20:33 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-09-30 20:33 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6a552015b9c4b2e029a47f44f1866578e3af5bd0
commit r11-10281-g6a552015b9c4b2e029a47f44f1866578e3af5bd0
Author: Harald Anlauf <anlauf@gmx.de>
Date: Tue Aug 23 22:16:14 2022 +0200
Fortran: improve error recovery while simplifying size of bad array [PR103694]
gcc/fortran/ChangeLog:
PR fortran/103694
* simplify.c (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)
Diff:
---
gcc/fortran/simplify.c | 5 +++--
gcc/testsuite/gfortran.dg/pr103694.f90 | 11 +++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index a1834e33081..3b033a6be92 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -7488,8 +7488,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
index 00000000000..3ed8b2088da
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr103694.f90
@@ -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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-30 20:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 20:33 [gcc r11-10281] Fortran: improve error recovery while simplifying size of bad array [PR103694] 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).