This check was somehow missed when adding the parsing support
for 'omp declare target local(...)' and 'omp groupprivate'.
I intent to commit it later, unless there are comments.
Thanks,
Tobias
Fortran/OpenMP: Reject device-local var in MAP clause
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses): Reject groupprivate/device-local
variables in MAP clauses.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/groupprivate-7.f90: New test.
gcc/fortran/openmp.cc | 6 ++++++
gcc/testsuite/gfortran.dg/gomp/groupprivate-7.f90 | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 5823ac41fa5..af3cb54ad56 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -9890,6 +9890,12 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
&n->where);
}
}
+ if (list == OMP_LIST_MAP
+ && (n->sym->attr.omp_groupprivate
+ || n->sym->attr.omp_declare_target_local))
+ gfc_error ("%qs argument to MAP clause at %L must not be a "
+ "device-local variable, including GROUPPRIVATE",
+ n->sym->name, &n->where);
if (openacc
&& list == OMP_LIST_MAP
&& (n->u.map.op == OMP_MAP_ATTACH
diff --git a/gcc/testsuite/gfortran.dg/gomp/groupprivate-7.f90 b/gcc/testsuite/gfortran.dg/gomp/groupprivate-7.f90
new file mode 100644
index 00000000000..408009b3d68
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/groupprivate-7.f90
@@ -0,0 +1,21 @@
+module m
+implicit none
+integer :: x
+!$omp declare target local(x)
+contains
+subroutine f
+integer, save :: y
+integer :: z
+common /com/ z
+
+! A variable that is a groupprivate variable or a device-local variable must
+! not appear as a list item in a map clause.
+
+!$omp groupprivate(y)
+!$omp groupprivate(/com/)
+!$omp target enter data map(x) ! { dg-error "'x' argument to MAP clause at .1. must not be a device-local variable, including GROUPPRIVATE" }
+!$omp target enter data map(y) ! { dg-error "'y' argument to MAP clause at .1. must not be a device-local variable, including GROUPPRIVATE" }
+!!$omp target enter data map(to : /com/) ! -> PR fortran/92730
+end
+
+end module