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.
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)
--- /dev/null
+! { 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