[flang-commits] [flang] [Flang][OpenMP] Add semantic tests for threadprivate variables with host assoc (PR #134680)
via flang-commits
flang-commits at lists.llvm.org
Mon Apr 7 09:14:41 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-openmp
@llvm/pr-subscribers-flang-semantics
Author: Michael Klemm (mjklemm)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/134680.diff
2 Files Affected:
- (modified) flang/test/Semantics/OpenMP/default-none.f90 (+15)
- (added) flang/test/Semantics/OpenMP/threadprivate09.f90 (+32)
``````````diff
diff --git a/flang/test/Semantics/OpenMP/default-none.f90 b/flang/test/Semantics/OpenMP/default-none.f90
index 761c2385466a0..a56657ccee467 100644
--- a/flang/test/Semantics/OpenMP/default-none.f90
+++ b/flang/test/Semantics/OpenMP/default-none.f90
@@ -58,3 +58,18 @@ subroutine sub( aaa)
ccc= aaa(ip)
end do
end subroutine sub
+
+! Test that threadprivate variables with host association
+! have a predetermined DSA
+subroutine host_assoc()
+ integer, save :: i
+ !$omp threadprivate(i)
+ real, save :: r
+ !$omp threadprivate(r)
+contains
+ subroutine internal()
+!$omp parallel default(none)
+ print *, i, r
+!$omp end parallel
+ end subroutine internal
+end subroutine host_assoc
diff --git a/flang/test/Semantics/OpenMP/threadprivate09.f90 b/flang/test/Semantics/OpenMP/threadprivate09.f90
new file mode 100644
index 0000000000000..462f476ae3e1e
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/threadprivate09.f90
@@ -0,0 +1,32 @@
+! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
+! OpenMP Version 5.1
+! Check OpenMP construct validity for the following directives:
+! 2.21.2 Threadprivate Directive
+
+subroutine host_assoc_fail()
+ integer :: i
+ ! ERROR: A variable that appears in a THREADPRIVATE directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
+ !$omp threadprivate(i)
+ real :: r
+ ! ERROR: A variable that appears in a THREADPRIVATE directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
+ !$omp threadprivate(r)
+contains
+ subroutine internal()
+!$omp parallel
+ print *, i, r
+!$omp end parallel
+ end subroutine internal
+end subroutine host_assoc_fail
+
+subroutine host_assoc()
+ integer, save :: i
+ !$omp threadprivate(i)
+ real, save :: r
+ !$omp threadprivate(r)
+contains
+ subroutine internal()
+!$omp parallel
+ print *, i, r
+!$omp end parallel
+ end subroutine internal
+end subroutine host_assoc
``````````
</details>
https://github.com/llvm/llvm-project/pull/134680
More information about the flang-commits
mailing list