Skip to content

[flang][OpenMP] Accept firstprivate vars in copyprivate #80467

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 1 commit into from
Feb 6, 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
3 changes: 2 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,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