1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2
3! Check OpenMP 5.0 - 2.17.8 flush Construct
4! Restriction -
5! If memory-order-clause is release, acquire, or acq_rel, list items must not be specified on the flush directive.
6
7use omp_lib
8  implicit none
9
10  TYPE someStruct
11    REAL :: rr
12  end TYPE
13  integer :: i, a, b
14  real, DIMENSION(10) :: array
15  TYPE(someStruct) :: structObj
16
17  a = 1.0
18  !$omp parallel num_threads(4)
19  !No list flushes all.
20  if (omp_get_thread_num() == 1) THEN
21    !$omp flush
22  END IF
23
24  array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
25  !Only memory-order-clauses.
26  if (omp_get_thread_num() == 1) THEN
27    ! Not allowed clauses.
28    !ERROR: SEQ_CST clause is not allowed on the FLUSH directive
29    !$omp flush seq_cst
30    !ERROR: RELAXED clause is not allowed on the FLUSH directive
31    !$omp flush relaxed
32
33    ! Not allowed more than once.
34    !ERROR: At most one ACQ_REL clause can appear on the FLUSH directive
35    !$omp flush acq_rel acq_rel
36    !ERROR: At most one RELEASE clause can appear on the FLUSH directive
37    !$omp flush release release
38    !ERROR: At most one ACQUIRE clause can appear on the FLUSH directive
39    !$omp flush acquire acquire
40
41    ! Mix of allowed and not allowed.
42    !ERROR: SEQ_CST clause is not allowed on the FLUSH directive
43    !$omp flush seq_cst acquire
44  END IF
45
46  array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
47  ! No memory-order-clause only list-items.
48  if (omp_get_thread_num() == 2) THEN
49    !$omp flush (a)
50    !$omp flush (i, a, b)
51    !$omp flush (array, structObj%rr)
52    ! Too many flush with repeating list items.
53    !$omp flush (i, a, b, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, b, b, b, b)
54    !ERROR: No explicit type declared for 'notpresentitem'
55    !$omp flush (notPresentItem)
56  END IF
57
58  array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
59  if (omp_get_thread_num() == 3) THEN
60    !ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive
61    !$omp flush acq_rel (array)
62    !ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive
63    !$omp flush acq_rel (array, a, i)
64
65    array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
66    !ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive
67    !$omp flush release (array)
68    !ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive
69    !$omp flush release (array, a)
70
71    array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
72    !ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive
73    !$omp flush acquire (array)
74    !ERROR: If memory-order-clause is RELEASE, ACQUIRE, or ACQ_REL, list items must not be specified on the FLUSH directive
75    !$omp flush acquire (array, a, structObj%rr)
76  END IF
77  !$omp end parallel
78
79  !$omp parallel num_threads(4)
80    array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
81    !$omp master
82      !$omp flush (array)
83    !$omp end master
84  !$omp end parallel
85end
86
87