Skip to content

[flang][OpenMP] Allow loop iteration variables in DSA clauses #86194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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