public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10747] Fortran: improve error recovery on invalid array section
@ 2022-05-16 19:40 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-05-16 19:40 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9fed680237d2c4242d3273ab8f64c82231d5eeb7
commit r10-10747-g9fed680237d2c4242d3273ab8f64c82231d5eeb7
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Mar 9 21:58:26 2022 +0100
Fortran: improve error recovery on invalid array section
gcc/fortran/ChangeLog:
PR fortran/104849
* expr.c (find_array_section): Avoid NULL pointer dereference on
invalid array section.
gcc/testsuite/ChangeLog:
PR fortran/104849
* gfortran.dg/pr104849.f90: New test.
(cherry picked from commit 22015e77d3e45306077396b9de8a8a28bb67fb20)
Diff:
---
gcc/fortran/expr.c | 4 +++-
gcc/testsuite/gfortran.dg/pr104849.f90 | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index d19c6c9980b..3570ff00d1c 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1591,7 +1591,9 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
{
if ((begin && begin->expr_type != EXPR_CONSTANT)
|| (finish && finish->expr_type != EXPR_CONSTANT)
- || (step && step->expr_type != EXPR_CONSTANT))
+ || (step && step->expr_type != EXPR_CONSTANT)
+ || (!begin && !lower)
+ || (!finish && !upper))
{
t = false;
goto cleanup;
diff --git a/gcc/testsuite/gfortran.dg/pr104849.f90 b/gcc/testsuite/gfortran.dg/pr104849.f90
new file mode 100644
index 00000000000..ae221b5ba10
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr104849.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/104849 - ICE in find_array_section
+! Contributed by G.Steinmetz
+
+program p
+ integer, parameter :: a(:) = [1, 2] ! { dg-error "deferred shape" }
+ integer :: x(2)
+ data x /a(:)/ ! { dg-error "Invalid" }
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-16 19:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 19:40 [gcc r10-10747] Fortran: improve error recovery on invalid array section 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).