Skip to content

Commit 271fc05

Browse files
committed
[Flang][OpenMP] : Compilation error involving Fortran pointers and data-sharing attributes
Issue description: When DEFAULT DSA is NONE, all data refs must be listed in one of the data sharing clause. But when a Cray pointer is listed in one of the data sharing clause, Cray pointee can be used in parallel region. This is valid as per standard. "Cray pointees have the same data-sharing attribute as the storage with which their Cray pointers are associated." Solution: Added a check to discard checking Cray pointee when DEFAULT DSA is NONE. This patch has code changes and a test case.
1 parent d31406b commit 271fc05

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

flang/lib/Semantics/resolve-directives.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,9 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
19951995
// Exclude indices of sequential loops that are privatised in
19961996
// the scope of the parallel region, and not in this scope.
19971997
// TODO: check whether this should be caught in IsObjectWithDSA
1998-
!symbol->test(Symbol::Flag::OmpPrivate)) {
1998+
!symbol->test(Symbol::Flag::OmpPrivate) &&
1999+
// If the symbol is a CrayPointee, It cannot appear in DSA clause
2000+
!symbol->test(Symbol::Flag::CrayPointee)) {
19992001
context_.Say(name.source,
20002002
"The DEFAULT(NONE) clause requires that '%s' must be listed in "
20012003
"a data-sharing attribute clause"_err_en_US,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
!RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
subroutine test_crayptr
3+
implicit none
4+
integer :: I
5+
real*8 var(*)
6+
pointer(ivar,var)
7+
real*8 pointee(8)
8+
9+
pointee(1) = 42.0
10+
ivar = loc(pointee)
11+
12+
!$omp parallel num_threads(2) default(none) shared(ivar)
13+
print *, var(1)
14+
!$omp end parallel
15+
16+
end subroutine test_crayptr
17+

0 commit comments

Comments
 (0)