[flang-commits] [flang] 5850f6b - [Flang][OpenMP] Parse and semantically analyze common blocks in map clauses correctly (#89847)
via flang-commits
flang-commits at lists.llvm.org
Fri May 3 05:10:33 PDT 2024
Author: agozillon
Date: 2024-05-03T14:10:28+02:00
New Revision: 5850f6ba9b2c14d8457c6e8455483a20b2bf3636
URL: https://github.com/llvm/llvm-project/commit/5850f6ba9b2c14d8457c6e8455483a20b2bf3636
DIFF: https://github.com/llvm/llvm-project/commit/5850f6ba9b2c14d8457c6e8455483a20b2bf3636.diff
LOG: [Flang][OpenMP] Parse and semantically analyze common blocks in map clauses correctly (#89847)
Currently, you cannot provide the common block syntax that you should be
able to provide for map clauses (and that you can for declare target)
e.g.:
` !$omp target map(tofrom: /var/)`
This PR seeks to change that and allow this syntax via a small tweak,
which may also allow a wider range of types to be provided without issue
as well via the utilisation of ResolveOmpObject a helper function used
by the majority of other OmpObject handling clauses.
A by product of this change, is that we now emit an error for the
following syntax, when provided to map clauses with an assumed size
array:
`!$omp target map(arr(:))`
This seems inline with the specification from what I understand of it
(do feel free to correct me if that is not your reading or I am
incorrect!) and other OpenMP compilers i.e. gfortran, ifx, ifort.
Added:
Modified:
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/OpenMP/map-clause.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 318687508ff1f5..c99b1c413970ef 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -633,6 +633,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
[&](const auto &name) {},
},
ompObj.u);
+
+ ResolveOmpObject(ompObj, ompFlag);
}
}
diff --git a/flang/test/Semantics/OpenMP/map-clause.f90 b/flang/test/Semantics/OpenMP/map-clause.f90
index b46b2550b04eda..a7430c3edeb949 100644
--- a/flang/test/Semantics/OpenMP/map-clause.f90
+++ b/flang/test/Semantics/OpenMP/map-clause.f90
@@ -2,9 +2,12 @@
! Check OpenMP MAP clause validity. Section 5.8.3 OpenMP 5.2.
subroutine sb(arr)
+ implicit none
real(8) :: arr(*)
real :: a
-
+ integer:: b, c, i
+ common /var/ b, c
+
!ERROR: Assumed-size whole arrays may not appear on the MAP clause
!$omp target map(arr)
do i = 1, 100
@@ -12,6 +15,7 @@ subroutine sb(arr)
enddo
!$omp end target
+ !ERROR: Assumed-size array 'arr' must have explicit final subscript upper bound value
!$omp target map(arr(:))
do i = 1, 100
a = 3.14
@@ -23,4 +27,9 @@ subroutine sb(arr)
a = 3.14
enddo
!$omp end target
+
+ !$omp target map(tofrom: /var/)
+ b = 1
+ c = 2
+ !$omp end target
end subroutine
More information about the flang-commits
mailing list