Skip to content

Commit e686695

Browse files
authored
[flang][OpenMP] Accept firstprivate vars in copyprivate (#80467)
This is patch 1 of 4, to add support for COPYPRIVATE. Original PR: #73128
1 parent a18e92d commit e686695

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2467,7 +2467,8 @@ void OmpAttributeVisitor::CheckDataCopyingClause(
24672467
// either 'private' or 'threadprivate' in enclosing context.
24682468
if (!checkSymbol->test(Symbol::Flag::OmpThreadprivate) &&
24692469
!(HasSymbolInEnclosingScope(symbol, currScope()) &&
2470-
symbol.test(Symbol::Flag::OmpPrivate))) {
2470+
(symbol.test(Symbol::Flag::OmpPrivate) ||
2471+
symbol.test(Symbol::Flag::OmpFirstPrivate)))) {
24712472
context_.Say(name.source,
24722473
"COPYPRIVATE variable '%s' is not PRIVATE or THREADPRIVATE in "
24732474
"outer context"_err_en_US,

flang/test/Semantics/OpenMP/copyprivate03.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ program omp_copyprivate
3434
!$omp end parallel
3535
!$omp end parallel sections
3636

37+
!The use of FIRSTPRIVATE with COPYPRIVATE is allowed
38+
!$omp parallel firstprivate(a)
39+
!$omp single
40+
a = a + k
41+
!$omp end single copyprivate(a)
42+
!$omp end parallel
43+
3744
print *, a, b
3845

3946
end program omp_copyprivate

0 commit comments

Comments
 (0)