Skip to content

Commit edcf65d

Browse files
authored
[flang][OpenMP] Allow loop iteration variables in DSA clauses (#86194)
Iteration variables of non-associated loops may be listed in DSA clauses. Fixes #78938
1 parent 6b8bb29 commit edcf65d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,15 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
16491649
break;
16501650
}
16511651
}
1652+
// If this symbol already has a data-sharing attribute then there is nothing
1653+
// to do here.
1654+
if (const Symbol * symbol{iv.symbol}) {
1655+
for (auto symMap : targetIt->objectWithDSA) {
1656+
if (symMap.first->name() == symbol->name()) {
1657+
return;
1658+
}
1659+
}
1660+
}
16521661
// If this symbol is already Private or Firstprivate in the enclosing
16531662
// OpenMP parallel or task then there is nothing to do here.
16541663
if (auto *symbol{targetIt->scope.FindSymbol(iv.source)}) {

flang/test/Semantics/OpenMP/do20.f90

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp
2+
3+
! OpenMP 5.2 5.1.1
4+
! Iteration variables of non-associated loops may be listed in DSA clauses.
5+
6+
!DEF: /shared_iv (Subroutine)Subprogram
7+
subroutine shared_iv
8+
!DEF: /shared_iv/i ObjectEntity INTEGER(4)
9+
integer i
10+
11+
!$omp parallel shared(i)
12+
!$omp single
13+
!REF: /shared_iv/i
14+
do i = 0, 1
15+
end do
16+
!$omp end single
17+
!$omp end parallel
18+
end subroutine

0 commit comments

Comments
 (0)