Skip to content

Commit

Permalink
[flang][OpenMP] Accept firstprivate vars in copyprivate (#80467)
Browse files Browse the repository at this point in the history
This is patch 1 of 4, to add support for COPYPRIVATE.
Original PR: #73128
  • Loading branch information
luporl committed Feb 6, 2024
1 parent a18e92d commit e686695
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,8 @@ void OmpAttributeVisitor::CheckDataCopyingClause(
// either 'private' or 'threadprivate' in enclosing context.
if (!checkSymbol->test(Symbol::Flag::OmpThreadprivate) &&
!(HasSymbolInEnclosingScope(symbol, currScope()) &&
symbol.test(Symbol::Flag::OmpPrivate))) {
(symbol.test(Symbol::Flag::OmpPrivate) ||
symbol.test(Symbol::Flag::OmpFirstPrivate)))) {
context_.Say(name.source,
"COPYPRIVATE variable '%s' is not PRIVATE or THREADPRIVATE in "
"outer context"_err_en_US,
Expand Down
7 changes: 7 additions & 0 deletions flang/test/Semantics/OpenMP/copyprivate03.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ program omp_copyprivate
!$omp end parallel
!$omp end parallel sections

!The use of FIRSTPRIVATE with COPYPRIVATE is allowed
!$omp parallel firstprivate(a)
!$omp single
a = a + k
!$omp end single copyprivate(a)
!$omp end parallel

print *, a, b

end program omp_copyprivate

0 comments on commit e686695

Please sign in to comment.