Hi Jerry, That is a cunning patch! I suggest that the comment before replace_in_expr_recursive be updated to reflect this new usage? eg.:
/* Given a FORALL or DO CONCURRENT, containing associate blocks, constructs. 1) Resolve the iterators. 2) Check for shadow index-name(s) and update code block. 3) call gfc_resolve_forall_body to resolve the body. */ /* Custom recursive expression walker that replaces symbols. This ensures we visit ALL expressions including those in array subscripts. */ OK for mainline and backporting. Thanks for the patch. Paul On Fri, 5 Jun 2026 at 20:32, Jerry D <[email protected]> wrote: > > See attached patch. > > This fix is also straight forward. > > Regression tested on x86_64. > > OK for mainline and later backport to 16. > > Reagrds, > > Jerry > > --- > > When an ASSOCIATE body references inline type-spec iterator, > replace_in_code_recursive lacked a case for EXEC_BLOCK > (associate constructs). So, it silently skipped both > the ASSOCIATE selector expressions and the body when > replacing shadow iterator references. > > Add case EXEC_BLOCK to iterate over each selector's target > expression via replace_in_expr_recursive and recurse into > the body namespace's code list via replace_in_code_recursive. > > PR fortran/125532 > > Assisted by: Claude Sonnet 4.6 > > gcc/fortran/ChangeLog: > > * resolve.cc (replace_in_code_recursive): Add EXEC_BLOCK case to > replace shadow iterator references in ASSOCIATE selector expressions > and the ASSOCIATE body namespace. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/do_concurrent_assoc_iter_1.f90: New test. > ---
