[flang-commits] [flang] [flang][OpenMP] Accept firstprivate vars in copyprivate (PR #80467)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Fri Feb 2 09:47:03 PST 2024
https://github.com/luporl created https://github.com/llvm/llvm-project/pull/80467
This is patch 1 of 4, to add support for COPYPRIVATE.
Original PR: https://github.com/llvm/llvm-project/pull/73128
>From 7e542bf8eabba46d07913c2ea462b6e564e338e8 Mon Sep 17 00:00:00 2001
From: Leandro Lupori <leandro.lupori at linaro.org>
Date: Fri, 2 Feb 2024 14:24:30 -0300
Subject: [PATCH] [flang][OpenMP] Accept firstprivate vars in copyprivate
This is patch 1 of 4, to add support for COPYPRIVATE.
Original PR: https://github.com/llvm/llvm-project/pull/73128
---
flang/lib/Semantics/resolve-directives.cpp | 3 ++-
flang/test/Semantics/OpenMP/copyprivate03.f90 | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 2c570bc3abeb2..ef5a01c1ca821 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -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,
diff --git a/flang/test/Semantics/OpenMP/copyprivate03.f90 b/flang/test/Semantics/OpenMP/copyprivate03.f90
index eccc308b1d5ab..9d39fdb6b13c8 100644
--- a/flang/test/Semantics/OpenMP/copyprivate03.f90
+++ b/flang/test/Semantics/OpenMP/copyprivate03.f90
@@ -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
More information about the flang-commits
mailing list