]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran/OpenMP: Reject device-local var in MAP clause
authorTobias Burnus <tburnus@baylibre.com>
Tue, 27 Jan 2026 12:05:27 +0000 (13:05 +0100)
committerTobias Burnus <tburnus@baylibre.com>
Tue, 27 Jan 2026 12:05:27 +0000 (13:05 +0100)
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
gcc/testsuite/gfortran.dg/gomp/groupprivate-7.f90 [new file with mode: 0644]

index 5823ac41fa51b515271a8a1015fe0223bac94099..af3cb54ad561261e3c9e04301324a231efd6f400 100644 (file)
@@ -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 (file)
index 0000000..408009b
--- /dev/null
@@ -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