What's checked at runtime in do_check_4.f90 PROGRAM test IMPLICIT NONE INTEGER :: i DO i=1,100 CALL do_something() ENDDO CONTAINS SUBROUTINE do_something() IMPLICIT NONE DO i=1,10 ENDDO END SUBROUTINE do_something END PROGRAM test can also be tested at compile-time, with an error issued. As a matter of fact, I have a patch regtesting right now, I just wanted put this into bugzilla as an anchor.
The master branch has been updated by Thomas Kथà¤nig <tkoenig@gcc.gnu.org>: https://gcc.gnu.org/g:27eac9ee6137a6b5ae693b54cafa22bdc0cbcd5a commit r11-2578-g27eac9ee6137a6b5ae693b54cafa22bdc0cbcd5a Author: Thomas Koenig <tkoenig@gcc.gnu.org> Date: Wed Aug 5 18:37:32 2020 +0200 Static analysis for definition of DO index variables in contained procedures. When encountering a procedure call in a DO loop, this patch checks if the call is to a contained procedure, and if it is, check for changes in the index variable. gcc/fortran/ChangeLog: PR fortran/96469 * frontend-passes.c (doloop_contained_function_call): New function. (doloop_contained_procedure_code): New function. (CHECK_INQ): Macro for inquire checks. (doloop_code): Invoke doloop_contained_procedure_code and doloop_contained_function_call if appropriate. (do_intent): Likewise. gcc/testsuite/ChangeLog: PR fortran/96469 * gfortran.dg/do_check_4.f90: Hide change in index variable from compile-time analysis. * gfortran.dg/do_check_13.f90: New test.
The master branch has been updated by Thomas Kथà¤nig <tkoenig@gcc.gnu.org>: https://gcc.gnu.org/g:dd30d93f1a3ead7b814c1b179cf7197e4bf1e183 commit r11-2579-gdd30d93f1a3ead7b814c1b179cf7197e4bf1e183 Author: Thomas Koenig <tkoenig@gcc.gnu.org> Date: Wed Aug 5 20:53:44 2020 +0200 Added test case to make sure that legal cases still pass. gcc/testsuite/ChangeLog: PR fortran/96469 * gfortran.dg/do_check_14.f90: New test.
Fixed on trunk, closing.