This rather obvious patch fixes an ICE on valid which came about
because I did not handle EXEC_IOLENGTH as start of an I/O statement
when checking for the DO loop variable. This is an 11 regression.
gcc/fortran/ChangeLog:
PR fortran/99345
* frontend-passes.c (doloop_contained_procedure_code):
Properly handle EXEC_IOLENGTH.
gcc/testsuite/ChangeLog:
PR fortran/99345
* gfortran.dg/do_check_16.f90: New test.
* gfortran.dg/do_check_17.f90: New test.
case EXEC_READ:
case EXEC_WRITE:
case EXEC_INQUIRE:
+ case EXEC_IOLENGTH:
saved_io_op = last_io_op;
last_io_op = co->op;
break;
info->procedure->name, &info->where_do);
break;
+ case EXEC_IOLENGTH:
+ if (co->expr1 && co->expr1->symtree->n.sym == do_var)
+ gfc_error_now (errmsg, do_var->name, &co->expr1->where,
+ info->procedure->name, &info->where_do);
+ break;
+
default:
gcc_unreachable ();
}
--- /dev/null
+! { dg-do compile }
+program main
+ implicit none
+ integer :: iq,nq,recl
+ DO iq = 1, nq
+ call foobar ! { dg-error "redefined" }
+ ENDDO
+CONTAINS
+
+ subroutine foobar
+ inquire (iolength=nq) iq ! { dg-error "redefined" }
+ end subroutine foobar
+END program main
--- /dev/null
+! { dg-do compile }
+! PR 99345 - this used to cause an ICE.
+! Original test case by Matthias Klose
+program main
+ implicit none
+ integer :: iq,nq,recl
+ DO iq = 1, nq
+ CALL calc_upper_fan (iq)
+ ENDDO
+CONTAINS
+ SUBROUTINE calc_upper_fan (iq)
+ INTEGER :: iq
+ INTEGER :: recl
+ INQUIRE(IOLENGTH=recl) iq
+ END SUBROUTINE calc_upper_fan
+END