xref: /llvm-project/flang/test/Semantics/OpenMP/nested-master.f90 (revision e67e09a77ea1e4802c0f6bc0409c9f5e9d1fae9a)
1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2! OpenMP Version 4.5
3! Various checks with the nesting of MASTER construct
4
5program omp_nest_master
6  integer i, k, j
7  k = 0;
8
9  !$omp do
10  do i = 1, 10
11    k = k + 1
12    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
13    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
14    !$omp master
15    j = j -1
16    !$omp end master
17  end do
18
19  !$omp sections
20  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
21  !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
22    !$omp master
23    do i = 1, 10
24      k = k + 1
25    end do
26    !$omp end master
27  !$omp end sections
28
29  !$omp single
30  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
31  !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
32    !$omp master
33    do i = 1, 10
34      k = k + 1
35    end do
36    !$omp end master
37  !$omp end single
38
39
40
41  !$omp task
42  do i = 1, 10
43    k = k + 1
44    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
45    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
46    !$omp master
47    j = j -1
48    !$omp end master
49  end do
50  !$omp end task
51
52  !$omp taskloop
53  do i = 1, 10
54    k = k + 1
55    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
56    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
57    !$omp master
58    j = j -1
59    !$omp end master
60  end do
61  !$omp end taskloop
62
63  !$omp target parallel do simd
64  do i = 1, 10
65    k = k + 1
66    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
67    !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct, the `SCAN` construct and the `ORDERED` construct with the `SIMD` clause.
68    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
69    !$omp master
70    j = j -1
71    !$omp end master
72  end do
73  !$omp end target parallel do simd
74
75  !$omp critical
76  do i = 1, 10
77    k = k + 1
78    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
79    !$omp master
80    j = j -1
81    !$omp end master
82  end do
83  !$omp end critical
84
85  !$omp ordered
86  do i = 1, 10
87    k = k + 1
88    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
89    !$omp master
90    j = j -1
91    !$omp end master
92  end do
93  !$omp end ordered
94
95  !$omp ordered
96  do i = 1, 10
97    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
98    !$omp teams
99    !$omp distribute
100    do k =1, 10
101      print *, "hello"
102      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
103      !$omp master
104      j = j -1
105      !$omp end master
106    end do
107    !$omp end distribute
108    !$omp end teams
109  end do
110  !$omp end ordered
111
112  !$omp critical
113  do i = 1, 10
114    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
115    !$omp teams
116    !$omp distribute
117    do k =1, 10
118      print *, "hello"
119      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
120      !$omp master
121      j = j -1
122      !$omp end master
123    end do
124    !$omp end distribute
125    !$omp end teams
126  end do
127  !$omp end critical
128
129  !$omp taskloop
130  do i = 1, 10
131    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
132    !$omp teams
133    !$omp distribute
134    do k =1, 10
135      print *, "hello"
136      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
137      !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
138      !$omp master
139      j = j -1
140      !$omp end master
141    end do
142    !$omp end distribute
143    !$omp end teams
144  end do
145  !$omp end taskloop
146
147  !$omp task
148  do i = 1, 10
149    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
150    !$omp teams
151    !$omp distribute
152    do k =1, 10
153      print *, "hello"
154      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
155      !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
156      !$omp master
157      j = j -1
158      !$omp end master
159    end do
160    !$omp end distribute
161    !$omp end teams
162  end do
163  !$omp end task
164
165end program omp_nest_master
166