Skip to content

Commit 5850f6b

Browse files
authored
[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.
1 parent 91446e2 commit 5850f6b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
633633
[&](const auto &name) {},
634634
},
635635
ompObj.u);
636+
637+
ResolveOmpObject(ompObj, ompFlag);
636638
}
637639
}
638640

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
! Check OpenMP MAP clause validity. Section 5.8.3 OpenMP 5.2.
33

44
subroutine sb(arr)
5+
implicit none
56
real(8) :: arr(*)
67
real :: a
7-
8+
integer:: b, c, i
9+
common /var/ b, c
10+
811
!ERROR: Assumed-size whole arrays may not appear on the MAP clause
912
!$omp target map(arr)
1013
do i = 1, 100
1114
a = 3.14
1215
enddo
1316
!$omp end target
1417

18+
!ERROR: Assumed-size array 'arr' must have explicit final subscript upper bound value
1519
!$omp target map(arr(:))
1620
do i = 1, 100
1721
a = 3.14
@@ -23,4 +27,9 @@ subroutine sb(arr)
2327
a = 3.14
2428
enddo
2529
!$omp end target
30+
31+
!$omp target map(tofrom: /var/)
32+
b = 1
33+
c = 2
34+
!$omp end target
2635
end subroutine

0 commit comments

Comments
 (0)