1! { dg-do run }
2! { dg-options "-fcray-pointer" }
3! { dg-require-effective-target tls_runtime }
4
5  use omp_lib
6  integer :: a, b, c, d, p
7  logical :: l
8  pointer (ip, p)
9  save ip
10!$omp threadprivate (ip)
11  a = 1
12  b = 2
13  c = 3
14  l = .false.
15!$omp parallel num_threads (3) reduction (.or.:l) private (d)
16  if (omp_get_thread_num () .eq. 0) then
17    ip = loc (a)
18  elseif (omp_get_thread_num () .eq. 1) then
19    ip = loc (b)
20  else
21    ip = loc (c)
22  end if
23  l = p .ne. omp_get_thread_num () + 1
24!$omp single
25  d = omp_get_thread_num ()
26!$omp end single copyprivate (d, ip)
27  l = l .or. (p .ne. d + 1)
28!$omp end parallel
29
30  if (l) STOP 1
31end
32