Fortran: Fix scope for OMP AFFINITY clause iterator variables [PR103695]
authorSandra Loosemore <sandra@codesourcery.com>
Thu, 20 Jan 2022 21:29:48 +0000 (13:29 -0800)
committerSandra Loosemore <sandra@codesourcery.com>
Thu, 20 Jan 2022 21:29:48 +0000 (13:29 -0800)
commitd2ad748eeef0dd260f3993b8dcbffbded3240a0a
treeccc475f58a559c1f528b3fef13530640b18160c3
parentcc01cd9397fe99e707bcc5b98bb33d807ba610d7
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  <sandra@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.
gcc/fortran/dump-parse-tree.cc
gcc/fortran/gfortran.h
gcc/fortran/openmp.cc
gcc/fortran/trans-decl.cc
gcc/fortran/trans-openmp.cc
gcc/testsuite/gfortran.dg/gomp/affinity-clause-3.f90
gcc/testsuite/gfortran.dg/gomp/pr102621.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/pr103695.f90 [new file with mode: 0644]