1! { dg-do run }
2
3! Test chaining of detached tasks, with each task fulfilling the
4! completion event of the previous one.
5
6program task_detach_1
7  use omp_lib
8
9  integer (kind=omp_event_handle_kind) :: detach_event1, detach_event2
10  integer :: x = 0, y = 0, z = 0
11
12  !$omp parallel
13    !$omp single
14      !$omp task detach (detach_event1)
15        x = x + 1
16      !$omp end task
17
18      !$omp task detach (detach_event2)
19        y = y + 1
20	call omp_fulfill_event (detach_event1)
21      !$omp end task
22
23      !$omp task
24        z = z + 1
25	call omp_fulfill_event (detach_event2)
26      !$omp end task
27    !$omp end single
28  !$omp end parallel
29
30  if (x /= 1) stop 1
31  if (y /= 1) stop 2
32  if (z /= 1) stop 3
33end program
34