Skip to content

Commit

Permalink
[flang][OpenMP] Allow loop iteration variables in DSA clauses (#86194)
Browse files Browse the repository at this point in the history
Iteration variables of non-associated loops may be listed in DSA
clauses.

Fixes #78938
  • Loading branch information
luporl committed Mar 25, 2024
1 parent 6b8bb29 commit edcf65d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,15 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
break;
}
}
// If this symbol already has a data-sharing attribute then there is nothing
// to do here.
if (const Symbol * symbol{iv.symbol}) {
for (auto symMap : targetIt->objectWithDSA) {
if (symMap.first->name() == symbol->name()) {
return;
}
}
}
// If this symbol is already Private or Firstprivate in the enclosing
// OpenMP parallel or task then there is nothing to do here.
if (auto *symbol{targetIt->scope.FindSymbol(iv.source)}) {
Expand Down
18 changes: 18 additions & 0 deletions flang/test/Semantics/OpenMP/do20.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp

! OpenMP 5.2 5.1.1
! Iteration variables of non-associated loops may be listed in DSA clauses.

!DEF: /shared_iv (Subroutine)Subprogram
subroutine shared_iv
!DEF: /shared_iv/i ObjectEntity INTEGER(4)
integer i

!$omp parallel shared(i)
!$omp single
!REF: /shared_iv/i
do i = 0, 1
end do
!$omp end single
!$omp end parallel
end subroutine

0 comments on commit edcf65d

Please sign in to comment.