public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10343] Fortran: prevent NULL pointer dereference in check of passed do-loop variable
@ 2021-12-16 22:22 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2021-12-16 22:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b99da5f23e122af800c1fca77e03664e686ae575
commit r10-10343-gb99da5f23e122af800c1fca77e03664e686ae575
Author: Harald Anlauf <anlauf@gmx.de>
Date: Tue Dec 14 21:57:04 2021 +0100
Fortran: prevent NULL pointer dereference in check of passed do-loop variable
gcc/fortran/ChangeLog:
PR fortran/103717
* frontend-passes.c (doloop_code): Prevent NULL pointer
dereference when checking for passing a do-loop variable to a
contained procedure with an interface mismatch.
gcc/testsuite/ChangeLog:
PR fortran/103717
* gfortran.dg/do_check_19.f90: New test.
(cherry picked from commit ca39102e10643a6b3f07d06934cc0907ba83d9ee)
Diff:
---
gcc/fortran/frontend-passes.c | 2 +-
gcc/testsuite/gfortran.dg/do_check_19.f90 | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index de9eff82630..cbadb9c1b22 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -2414,7 +2414,7 @@ doloop_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED,
do_sym = cl->ext.iterator->var->symtree->n.sym;
- if (a->expr && a->expr->symtree
+ if (a->expr && a->expr->symtree && f->sym
&& a->expr->symtree->n.sym == do_sym)
{
if (f->sym->attr.intent == INTENT_OUT)
diff --git a/gcc/testsuite/gfortran.dg/do_check_19.f90 b/gcc/testsuite/gfortran.dg/do_check_19.f90
new file mode 100644
index 00000000000..1373a7374ce
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_check_19.f90
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! { dg-prune-output "Obsolescent feature: Alternate-return argument" }
+! PR fortran/103717 - ICE in doloop_code
+! Contributed by G.Steinmetz
+
+program p
+ integer :: i
+ do i = 1, 2
+ call s(i) ! { dg-error "Missing alternate return specifier" }
+ end do
+contains
+ subroutine s(*)
+ end
+end
+
+recursive subroutine s(*)
+ integer :: i
+ do i = 1, 2
+ call s(i) ! { dg-error "Missing alternate return specifier" }
+ end do
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-16 22:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 22:22 [gcc r10-10343] Fortran: prevent NULL pointer dereference in check of passed do-loop variable 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).