Skip to content

Commit 95b3e14

Browse files
committed
[flang][OpenMP] Accept firstprivate vars in copyprivate
This is patch 1 of 4, to add support for COPYPRIVATE. Original PR: llvm#73128
1 parent 5330daa commit 95b3e14

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
@@ -2429,7 +2429,8 @@ void OmpAttributeVisitor::CheckDataCopyingClause(
24292429
// either 'private' or 'threadprivate' in enclosing context.
24302430
if (!checkSymbol->test(Symbol::Flag::OmpThreadprivate) &&
24312431
!(HasSymbolInEnclosingScope(symbol, currScope()) &&
2432-
symbol.test(Symbol::Flag::OmpPrivate))) {
2432+
(symbol.test(Symbol::Flag::OmpPrivate) ||
2433+
symbol.test(Symbol::Flag::OmpFirstPrivate)))) {
24332434
context_.Say(name.source,
24342435
"COPYPRIVATE variable '%s' is not PRIVATE or THREADPRIVATE in "
24352436
"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)