| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/120286 - scalar class pointers in OpenMP private/firstprivate |
| 4 |
! clauses must preserve association status without taking ownership. |
| 5 |
|
| 6 |
program main |
| 7 |
implicit none |
| 8 |
|
| 9 |
type foo_t |
| 10 |
integer :: dummy |
| 11 |
end type foo_t |
| 12 |
|
| 13 |
type fooPtr_t |
| 14 |
class(foo_t), pointer :: p |
| 15 |
end type fooPtr_t |
| 16 |
|
| 17 |
type fooPtrStack_t |
| 18 |
class(fooPtr_t), allocatable :: list(:) |
| 19 |
end type fooPtrStack_t |
| 20 |
|
| 21 |
type(fooPtrStack_t) :: x |
| 22 |
class(foo_t), pointer :: ptr |
| 23 |
integer :: it, n |
| 24 |
logical :: ok |
| 25 |
|
| 26 |
allocate (x%list(1)) |
| 27 |
allocate (x%list(1)%p) |
| 28 |
x%list(1)%p%dummy = 7 |
| 29 |
|
| 30 |
do it = 1, 16 |
| 31 |
!$omp parallel do default(none) num_threads(2) private(n, ptr) shared(x) |
| 32 |
do n = 1, 1 |
| 33 |
ptr => x%list(n)%p |
| 34 |
end do |
| 35 |
!$omp end parallel do |
| 36 |
end do |
| 37 |
|
| 38 |
if (.not. associated (x%list(1)%p)) stop 1 |
| 39 |
if (x%list(1)%p%dummy /= 7) stop 2 |
| 40 |
|
| 41 |
ptr => x%list(1)%p |
| 42 |
ok = .false. |
| 43 |
|
| 44 |
!$omp parallel default(none) num_threads(1) firstprivate(ptr) shared(x, ok) |
| 45 |
ok = associated (ptr, x%list(1)%p) .and. ptr%dummy == 7 |
| 46 |
!$omp end parallel |
| 47 |
|
| 48 |
if (.not. ok) stop 3 |
| 49 |
end program main |