[flang-commits] [flang] 38e4656 - [Flang][OpenMP] Issue error for assumed-size array in Map clause

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Wed Mar 29 09:21:16 PDT 2023


Author: Kiran Chandramohan
Date: 2023-03-29T16:20:50Z
New Revision: 38e465686c61c581b37f13418ba3e83a1aedc278

URL: https://github.com/llvm/llvm-project/commit/38e465686c61c581b37f13418ba3e83a1aedc278
DIFF: https://github.com/llvm/llvm-project/commit/38e465686c61c581b37f13418ba3e83a1aedc278.diff

LOG: [Flang][OpenMP] Issue error for assumed-size array in Map clause

Error only applies if it is a whole array. Page 157 in OpenMP 5.2
standard.

Reviewed By: TIFitis

Differential Revision: https://reviews.llvm.org/D147142

Added: 
    flang/test/Semantics/OpenMP/map-clause.f90

Modified: 
    flang/lib/Semantics/resolve-directives.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index f16f53c578b22..1bb1e67f89304 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -462,6 +462,28 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
   void Post(const parser::EndLabel &endLabel) { CheckSourceLabel(endLabel.v); }
   void Post(const parser::EorLabel &eorLabel) { CheckSourceLabel(eorLabel.v); }
 
+  void Post(const parser::OmpMapClause &x) {
+    const auto &ompObjList{std::get<parser::OmpObjectList>(x.t)};
+    for (const auto &ompObj : ompObjList.v) {
+      common::visit(
+          common::visitors{
+              [&](const parser::Designator &designator) {
+                if (const auto *name{GetDesignatorNameIfDataRef(designator)}) {
+                  if (name->symbol &&
+                      semantics::IsAssumedSizeArray(*name->symbol)) {
+                    context_.Say(designator.source,
+                        "Assumed-size whole arrays may not appear on the %s "
+                        "clause"_err_en_US,
+                        "MAP");
+                  }
+                }
+              },
+              [&](const auto &name) {},
+          },
+          ompObj.u);
+    }
+  }
+
   const parser::OmpClause *associatedClause{nullptr};
   void SetAssociatedClause(const parser::OmpClause &c) {
     associatedClause = &c;

diff  --git a/flang/test/Semantics/OpenMP/map-clause.f90 b/flang/test/Semantics/OpenMP/map-clause.f90
new file mode 100644
index 0000000000000..b46b2550b04ed
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/map-clause.f90
@@ -0,0 +1,26 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! Check OpenMP MAP clause validity. Section 5.8.3 OpenMP 5.2.
+
+subroutine sb(arr)
+  real(8) :: arr(*)
+  real :: a
+
+  !ERROR: Assumed-size whole arrays may not appear on the MAP clause
+  !$omp target map(arr)
+  do i = 1, 100
+     a = 3.14
+  enddo
+  !$omp end target
+
+  !$omp target map(arr(:))
+  do i = 1, 100
+     a = 3.14
+  enddo
+  !$omp end target
+
+  !$omp target map(arr(3:5))
+  do i = 1, 100
+     a = 3.14
+  enddo
+  !$omp end target
+end subroutine


        


More information about the flang-commits mailing list