https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127128
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:c6625b9b13ab6369a2645ac838b38570d0e86571 commit r17-3796-gc6625b9b13ab6369a2645ac838b38570d0e86571 Author: Jerry DeLisle <[email protected]> Date: Sat Aug 29 09:52:16 2026 -0700 fortran: [PR127128] wrong code with DO CONCURRENT type-spec index-name A type-spec in a DO CONCURRENT concurrent-header gives the index-name construct scope. The front end implements this by creating a shadow variable and substituting it for the index-name throughout the construct body. The hand-written walkers that perform the substitution covered only a subset of the expression and statement forms, so references left behind still pointed at the enclosing scope's variable. The construct then indexed with an unrelated, often undefined, value. Replace the expression walker with a gfc_traverse_expr callback so that every expression form is covered, and extend the statement walker to the forms it was missing: the branch chains of IF and WHERE constructs, the allocate-objects of ALLOCATE and DEALLOCATE, and the case lists of SELECT TYPE and SELECT RANK. PR fortran/127128 gcc/fortran/ChangeLog: * resolve.cc (replace_forall_var): New function. (replace_in_expr_recursive): Traverse with gfc_traverse_expr instead of walking the expression by hand. (replace_in_code_recursive): Substitute in the whole branch chain of IF and WHERE constructs, in the allocate-objects of ALLOCATE and DEALLOCATE, and in SELECT TYPE and SELECT RANK case lists. gcc/testsuite/ChangeLog: * gfortran.dg/do_concurrent_typespec_5.f90: New test.
