1! RUN: %python %S/../test_errors.py %s %flang -fopenmp 2 3! OpenMP Version 5.0 4! Check OpenMP construct validity for the following directives: 5! 2.18.1 Cancel Construct 6 7program main 8 integer :: i, N = 10 9 real :: a 10 11 !ERROR: CANCEL TASKGROUP directive is not closely nested inside TASK or TASKLOOP 12 !$omp cancel taskgroup 13 14 !ERROR: CANCEL SECTIONS directive is not closely nested inside SECTION or SECTIONS 15 !$omp cancel sections 16 17 !ERROR: CANCEL DO directive is not closely nested inside the construct that matches the DO clause type 18 !$omp cancel do 19 20 !ERROR: CANCEL PARALLEL directive is not closely nested inside the construct that matches the PARALLEL clause type 21 !$omp cancel parallel 22 23 !$omp parallel 24 !$omp sections 25 !$omp cancel sections 26 !$omp section 27 a = 3.14 28 !$omp end sections 29 !$omp end parallel 30 31 !$omp sections 32 !$omp section 33 !$omp cancel sections 34 a = 3.14 35 !$omp end sections 36 37 !$omp parallel 38 !ERROR: With SECTIONS clause, CANCEL construct cannot be closely nested inside PARALLEL construct 39 !$omp cancel sections 40 a = 3.14 41 !$omp end parallel 42 43 !$omp parallel sections 44 !$omp cancel sections 45 a = 3.14 46 !$omp end parallel sections 47 48 !$omp do 49 do i = 1, N 50 a = 3.14 51 !$omp cancel do 52 end do 53 !$omp end do 54 55 !$omp parallel do 56 do i = 1, N 57 a = 3.14 58 !$omp cancel do 59 end do 60 !$omp end parallel do 61 62 !$omp target 63 !$omp teams 64 !$omp distribute parallel do 65 do i = 1, N 66 a = 3.14 67 !$omp cancel do 68 end do 69 !$omp end distribute parallel do 70 !$omp end teams 71 !$omp end target 72 73 !$omp target 74 !$omp teams distribute parallel do 75 do i = 1, N 76 a = 3.14 77 !$omp cancel do 78 end do 79 !$omp end teams distribute parallel do 80 !$omp end target 81 82 !$omp target teams distribute parallel do 83 do i = 1, N 84 a = 3.14 85 !$omp cancel do 86 end do 87 !$omp end target teams distribute parallel do 88 89 !$omp target parallel do 90 do i = 1, N 91 a = 3.14 92 !$omp cancel do 93 end do 94 !$omp end target parallel do 95 96 !$omp parallel 97 do i = 1, N 98 a = 3.14 99 !ERROR: With DO clause, CANCEL construct cannot be closely nested inside PARALLEL construct 100 !$omp cancel do 101 end do 102 !$omp end parallel 103 104 !$omp parallel 105 do i = 1, N 106 a = 3.14 107 !$omp cancel parallel 108 end do 109 !$omp end parallel 110 111 !$omp target parallel 112 do i = 1, N 113 a = 3.14 114 !$omp cancel parallel 115 end do 116 !$omp end target parallel 117 118 !$omp target parallel do 119 do i = 1, N 120 a = 3.14 121 !ERROR: With PARALLEL clause, CANCEL construct cannot be closely nested inside TARGET PARALLEL DO construct 122 !$omp cancel parallel 123 end do 124 !$omp end target parallel do 125 126 !$omp do 127 do i = 1, N 128 a = 3.14 129 !ERROR: With PARALLEL clause, CANCEL construct cannot be closely nested inside DO construct 130 !$omp cancel parallel 131 end do 132 !$omp end do 133 134contains 135 subroutine sub1() 136 !$omp task 137 !$omp cancel taskgroup 138 a = 3.14 139 !$omp end task 140 141 !$omp taskloop 142 do i = 1, N 143 !$omp parallel 144 !$omp end parallel 145 !$omp cancel taskgroup 146 a = 3.14 147 end do 148 !$omp end taskloop 149 150 !$omp taskloop nogroup 151 do i = 1, N 152 !$omp cancel taskgroup 153 a = 3.14 154 end do 155 156 !$omp parallel 157 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region 158 !$omp cancel taskgroup 159 a = 3.14 160 !$omp end parallel 161 162 !$omp do 163 do i = 1, N 164 !$omp task 165 !$omp cancel taskgroup 166 a = 3.14 167 !$omp end task 168 end do 169 !$omp end do 170 171 !$omp parallel 172 !$omp taskgroup 173 !$omp task 174 !$omp cancel taskgroup 175 a = 3.14 176 !$omp end task 177 !$omp end taskgroup 178 !$omp end parallel 179 180 !$omp parallel 181 !$omp task 182 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region 183 !$omp cancel taskgroup 184 a = 3.14 185 !$omp end task 186 !$omp end parallel 187 188 !$omp parallel 189 !$omp do 190 do i = 1, N 191 !$omp task 192 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region 193 !$omp cancel taskgroup 194 a = 3.14 195 !$omp end task 196 end do 197 !$omp end do 198 !$omp end parallel 199 200 !$omp target parallel 201 !$omp task 202 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region 203 !$omp cancel taskgroup 204 a = 3.14 205 !$omp end task 206 !$omp end target parallel 207 208 !$omp parallel 209 !$omp taskloop private(j) nogroup 210 do i = 1, N 211 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region 212 !$omp cancel taskgroup 213 a = 3.14 214 end do 215 !$omp end taskloop 216 !$omp end parallel 217 218 !$omp parallel 219 !$omp taskloop 220 do i = 1, N 221 !$omp cancel taskgroup 222 a = 3.14 223 end do 224 !$omp end taskloop 225 !$omp end parallel 226 227 !$omp parallel 228 !$omp taskgroup 229 !$omp taskloop nogroup 230 do i = 1, N 231 !$omp cancel taskgroup 232 a = 3.14 233 end do 234 !$omp end taskloop 235 !$omp end taskgroup 236 !$omp end parallel 237 238 !$omp target parallel 239 !$omp taskloop nogroup 240 do i = 1, N 241 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region 242 !$omp cancel taskgroup 243 a = 3.14 244 end do 245 !$omp end taskloop 246 !$omp end target parallel 247 end subroutine sub1 248 249end program main 250