1! { dg-do run }
2
3  integer :: a, b, c
4  a = 1
5  b = 2
6  c = 3
7  call foo
8  if (a .ne. 7) stop 1
9contains
10  subroutine foo
11    use omp_lib
12    logical :: l
13    l = .false.
14!$omp parallel shared (a) private (b) firstprivate (c) &
15!$omp num_threads (2) reduction (.or.:l)
16    if (a .ne. 1 .or. c .ne. 3) l = .true.
17!$omp barrier
18    if (omp_get_thread_num () .eq. 0) then
19      a = 4
20      b = 5
21      c = 6
22    end if
23!$omp barrier
24    if (omp_get_thread_num () .eq. 1) then
25      if (a .ne. 4 .or. c .ne. 3) l = .true.
26      a = 7
27      b = 8
28      c = 9
29    else if (omp_get_num_threads () .eq. 1) then
30      a = 7
31    end if
32!$omp barrier
33    if (omp_get_thread_num () .eq. 0) then
34      if (a .ne. 7 .or. b .ne. 5 .or. c .ne. 6) l = .true.
35    end if
36!$omp barrier
37    if (omp_get_thread_num () .eq. 1) then
38      if (a .ne. 7 .or. b .ne. 8 .or. c .ne. 9) l = .true.
39    end if
40!$omp end parallel
41    if (l) stop 2
42  end subroutine foo
43end
44