https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102621
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Sandra Loosemore <san...@gcc.gnu.org>: https://gcc.gnu.org/g:d2ad748eeef0dd260f3993b8dcbffbded3240a0a commit r12-6780-gd2ad748eeef0dd260f3993b8dcbffbded3240a0a Author: Sandra Loosemore <san...@codesourcery.com> Date: Thu Jan 20 13:29:48 2022 -0800 Fortran: Fix scope for OMP AFFINITY clause iterator variables [PR103695] gfc_finish_var_decl was confused by the undocumented overloading of the proc_name field in struct gfc_namespace to contain iterator variables for the OpenMP AFFINITY clause, causing it to insert the decls in the wrong scope. This patch adds a new distinct field to hold these variables. 2022-01-20 Sandra Loosemore <san...@codesourcery.com> PR fortran/103695 PR fortran/102621 gcc/fortran * gfortran.h (struct gfc_namespace) Add omp_affinity_iterator field. * dump-parse-tree.cc (show_iterator): Use it. * openmp.cc (gfc_match_iterator): Likewise. (resolve_omp_clauses): Likewise. * trans-decl.cc (gfc_finish_var_decl): Likewise. * trans-openmp.cc (handle_iterator): Likewise. gcc/testsuite/ * gfortran.dg/gomp/affinity-clause-3.f90: Adjust pattern. * gfortran.dg/gomp/pr102621.f90: New. * gfortran.dg/gomp/pr103695.f90: New.