[flang-commits] [flang] [flang][OpenMP] Accept firstprivate vars in copyprivate (PR #80467)

via flang-commits flang-commits at lists.llvm.org
Fri Feb 2 09:47:31 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-openmp

Author: Leandro Lupori (luporl)

<details>
<summary>Changes</summary>

This is patch 1 of 4, to add support for COPYPRIVATE.
Original PR: https://github.com/llvm/llvm-project/pull/73128


---
Full diff: https://github.com/llvm/llvm-project/pull/80467.diff


2 Files Affected:

- (modified) flang/lib/Semantics/resolve-directives.cpp (+2-1) 
- (modified) flang/test/Semantics/OpenMP/copyprivate03.f90 (+7) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/80467


More information about the flang-commits mailing list