Skip to content

Commit 69c4e17

Browse files
authored
[Flang][OpenMP] Add semantic tests for threadprivate variables with host assoc (#134680)
1 parent c2c1031 commit 69c4e17

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

flang/test/Semantics/OpenMP/default-none.f90

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,18 @@ subroutine sub( aaa)
5858
ccc= aaa(ip)
5959
end do
6060
end subroutine sub
61+
62+
! Test that threadprivate variables with host association
63+
! have a predetermined DSA
64+
subroutine host_assoc()
65+
integer, save :: i
66+
!$omp threadprivate(i)
67+
real, save :: r
68+
!$omp threadprivate(r)
69+
contains
70+
subroutine internal()
71+
!$omp parallel default(none)
72+
print *, i, r
73+
!$omp end parallel
74+
end subroutine internal
75+
end subroutine host_assoc
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2+
! OpenMP Version 5.1
3+
! Check OpenMP construct validity for the following directives:
4+
! 2.21.2 Threadprivate Directive
5+
6+
subroutine host_assoc_fail()
7+
integer :: i
8+
! 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
9+
!$omp threadprivate(i)
10+
real :: r
11+
! 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
12+
!$omp threadprivate(r)
13+
contains
14+
subroutine internal()
15+
!$omp parallel
16+
print *, i, r
17+
!$omp end parallel
18+
end subroutine internal
19+
end subroutine host_assoc_fail
20+
21+
! This sub-test is not supposed to emit a compiler error.
22+
subroutine host_assoc()
23+
integer, save :: i
24+
!$omp threadprivate(i)
25+
real, save :: r
26+
!$omp threadprivate(r)
27+
contains
28+
subroutine internal()
29+
!$omp parallel
30+
print *, i, r
31+
!$omp end parallel
32+
end subroutine internal
33+
end subroutine host_assoc

0 commit comments

Comments
 (0)