https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/176942

Backport eb7adafc68dcf5a86ce916d93df6a1e34fbb9688

Requested by: @kparzysz

>From dc59ec95e7decdbc937043bcd37023cce39a7b66 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <[email protected]>
Date: Mon, 19 Jan 2026 14:36:46 -0600
Subject: [PATCH] [flang][OpenMP] Allow ALLOC/RELEASE in place of STORAGE in
 6.0 (#176810)

As per the 6.0 spec

> The value alloc may be used on map-entering constructs and the value
> release may be used on map-exiting constructs with identical meaning to
> the value storage.

(cherry picked from commit eb7adafc68dcf5a86ce916d93df6a1e34fbb9688)
---
 flang/lib/Semantics/check-omp-structure.cpp   | 10 ++++---
 .../test/Semantics/OpenMP/map-clause-v60.f90  | 27 +++++++++++++++++++
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index 2acf0dee1f77e..44cb3c06936f7 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -4300,10 +4300,11 @@ void OmpStructureChecker::Enter(const 
parser::OmpClause::Map &x) {
     static auto isValidForVersion{
         [](parser::OmpMapType::Value t, unsigned version) {
           switch (t) {
-          case parser::OmpMapType::Value::Alloc:
           case parser::OmpMapType::Value::Delete:
-          case parser::OmpMapType::Value::Release:
             return version < 60;
+          case parser::OmpMapType::Value::Alloc:
+          case parser::OmpMapType::Value::Release:
+            return version <= 60;
           case parser::OmpMapType::Value::Storage:
             return version >= 60;
           default:
@@ -4336,8 +4337,9 @@ void OmpStructureChecker::Enter(const 
parser::OmpClause::Map &x) {
         llvm::is_contained(leafs, Directive::OMPD_target_data)) {
       if (version >= 60) {
         // Map types listed in the decay table. [6.0:276]
-        CheckAllowedMapTypes(
-            type->v, {Value::Storage, Value::From, Value::To, Value::Tofrom});
+        CheckAllowedMapTypes(type->v,
+            {Value::Alloc, Value::Release, Value::Storage, Value::From,
+                Value::To, Value::Tofrom});
       } else {
         CheckAllowedMapTypes(
             type->v, {Value::Alloc, Value::From, Value::To, Value::Tofrom});
diff --git a/flang/test/Semantics/OpenMP/map-clause-v60.f90 
b/flang/test/Semantics/OpenMP/map-clause-v60.f90
index 2c73f2edaa6b0..7327f930e234a 100644
--- a/flang/test/Semantics/OpenMP/map-clause-v60.f90
+++ b/flang/test/Semantics/OpenMP/map-clause-v60.f90
@@ -6,3 +6,30 @@ subroutine f00(a)
   !$omp target map(a)
   !$omp end target
 end
+
+subroutine f01
+  integer :: x
+  ! No diagnostic expected, alloc is allowed on map-entering constructs
+  !$omp target map(alloc: x)
+  !$omp end target
+end
+
+subroutine f02
+  integer :: x
+  ! No diagnostic expected, release is allowed on map-exiting constructs
+  !$omp target_data map(release: x)
+  !$omp end target_data
+end
+
+subroutine f03
+  integer :: x
+  ! No diagnostic expected, delete is its own modifier in 6.0+
+  !$omp target_data map(delete: x)
+  !$omp end target_data
+end
+
+subroutine f04
+  integer :: x
+  !ERROR: Only the FROM, RELEASE, STORAGE, TOFROM map types are permitted for 
MAP clauses on the TARGET_EXIT_DATA directive
+  !$omp target_exit_data map(alloc: x)
+end

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to