| 1 | // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s |
| 2 | |
| 3 | // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s |
| 4 | |
| 5 | // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute'}} |
| 6 | #pragma omp target teams distribute |
| 7 | |
| 8 | // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute'}} |
| 9 | #pragma omp target teams distribute foo |
| 10 | |
| 11 | void test_no_clause() { |
| 12 | int i; |
| 13 | #pragma omp target teams distribute |
| 14 | for (i = 0; i < 16; ++i) |
| 15 | ; |
| 16 | |
| 17 | // expected-error@+2 {{statement after '#pragma omp target teams distribute' must be a for loop}} |
| 18 | #pragma omp target teams distribute |
| 19 | ++i; |
| 20 | } |
| 21 | |
| 22 | void test_branch_protected_scope() { |
| 23 | int i = 0; |
| 24 | L1: |
| 25 | ++i; |
| 26 | |
| 27 | int x[24]; |
| 28 | |
| 29 | #pragma omp target teams distribute |
| 30 | for (i = 0; i < 16; ++i) { |
| 31 | if (i == 5) |
| 32 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 33 | else if (i == 6) |
| 34 | return; // expected-error {{cannot return from OpenMP region}} |
| 35 | else if (i == 7) |
| 36 | goto L2; |
| 37 | else if (i == 8) { |
| 38 | L2: |
| 39 | x[i]++; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | if (x[0] == 0) |
| 44 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 45 | else if (x[1] == 1) |
| 46 | goto L1; |
| 47 | } |
| 48 | |
| 49 | void test_invalid_clause() { |
| 50 | int i; |
| 51 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 52 | #pragma omp target teams distribute foo bar |
| 53 | for (i = 0; i < 16; ++i) |
| 54 | ; |
| 55 | } |
| 56 | |
| 57 | void test_non_identifiers() { |
| 58 | int i, x; |
| 59 | |
| 60 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 61 | #pragma omp target teams distribute; |
| 62 | for (i = 0; i < 16; ++i) |
| 63 | ; |
| 64 | |
| 65 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 66 | #pragma omp target teams distribute private(x); |
| 67 | for (i = 0; i < 16; ++i) |
| 68 | ; |
| 69 | |
| 70 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 71 | #pragma omp target teams distribute, private(x); |
| 72 | for (i = 0; i < 16; ++i) |
| 73 | ; |
| 74 | } |
| 75 | |
| 76 | extern int foo(); |
| 77 | |
| 78 | void test_collapse() { |
| 79 | int i; |
| 80 | // expected-error@+1 {{expected '('}} |
| 81 | #pragma omp target teams distribute collapse |
| 82 | for (i = 0; i < 16; ++i) |
| 83 | ; |
| 84 | // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 85 | #pragma omp target teams distribute collapse( |
| 86 | for (i = 0; i < 16; ++i) |
| 87 | ; |
| 88 | // expected-error@+1 {{expected expression}} |
| 89 | #pragma omp target teams distribute collapse() |
| 90 | for (i = 0; i < 16; ++i) |
| 91 | ; |
| 92 | // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 93 | #pragma omp target teams distribute collapse(, |
| 94 | for (i = 0; i < 16; ++i) |
| 95 | ; |
| 96 | // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 97 | #pragma omp target teams distribute collapse(, ) |
| 98 | for (i = 0; i < 16; ++i) |
| 99 | ; |
| 100 | // expected-warning@+2 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 101 | // expected-error@+1 {{expected '('}} |
| 102 | #pragma omp target teams distribute collapse 4) |
| 103 | for (i = 0; i < 16; ++i) |
| 104 | ; |
| 105 | // expected-error@+2 {{expected ')'}} |
| 106 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 107 | #pragma omp target teams distribute collapse(4 |
| 108 | for (i = 0; i < 16; ++i) |
| 109 | ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} |
| 110 | // expected-error@+2 {{expected ')'}} |
| 111 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 112 | #pragma omp target teams distribute collapse(4, |
| 113 | for (i = 0; i < 16; ++i) |
| 114 | ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} |
| 115 | // expected-error@+2 {{expected ')'}} |
| 116 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 117 | #pragma omp target teams distribute collapse(4, ) |
| 118 | for (i = 0; i < 16; ++i) |
| 119 | ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} |
| 120 | // expected-note@+1 {{as specified in 'collapse' clause}} |
| 121 | #pragma omp target teams distribute collapse(4) |
| 122 | for (i = 0; i < 16; ++i) |
| 123 | ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} |
| 124 | // expected-error@+2 {{expected ')'}} |
| 125 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 126 | #pragma omp target teams distribute collapse(4 4) |
| 127 | for (i = 0; i < 16; ++i) |
| 128 | ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} |
| 129 | // expected-error@+2 {{expected ')'}} |
| 130 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 131 | #pragma omp target teams distribute collapse(4, , 4) |
| 132 | for (i = 0; i < 16; ++i) |
| 133 | ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} |
| 134 | #pragma omp target teams distribute collapse(4) |
| 135 | for (int i1 = 0; i1 < 16; ++i1) |
| 136 | for (int i2 = 0; i2 < 16; ++i2) |
| 137 | for (int i3 = 0; i3 < 16; ++i3) |
| 138 | for (int i4 = 0; i4 < 16; ++i4) |
| 139 | foo(); |
| 140 | // expected-error@+2 {{expected ')'}} |
| 141 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 142 | #pragma omp target teams distribute collapse(4, 8) |
| 143 | for (i = 0; i < 16; ++i) |
| 144 | ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}} |
| 145 | // expected-error@+1 {{expression is not an integer constant expression}} |
| 146 | #pragma omp target teams distribute collapse(2.5) |
| 147 | for (i = 0; i < 16; ++i) |
| 148 | ; |
| 149 | // expected-error@+1 {{expression is not an integer constant expression}} |
| 150 | #pragma omp target teams distribute collapse(foo()) |
| 151 | for (i = 0; i < 16; ++i) |
| 152 | ; |
| 153 | // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 154 | #pragma omp target teams distribute collapse(-5) |
| 155 | for (i = 0; i < 16; ++i) |
| 156 | ; |
| 157 | // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 158 | #pragma omp target teams distribute collapse(0) |
| 159 | for (i = 0; i < 16; ++i) |
| 160 | ; |
| 161 | // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 162 | #pragma omp target teams distribute collapse(5 - 5) |
| 163 | for (i = 0; i < 16; ++i) |
| 164 | ; |
| 165 | // expected-error@+3 {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be firstprivate, predetermined as private}} |
| 166 | // expected-note@+1 {{defined as firstprivate}} |
| 167 | #pragma omp target teams distribute collapse(2) firstprivate(i) |
| 168 | for (i = 0; i < 16; ++i) |
| 169 | for (int j = 0; j < 16; ++j) |
| 170 | #pragma omp parallel for reduction(+ : i, j) |
| 171 | for (int k = 0; k < 16; ++k) |
| 172 | i += j; |
| 173 | } |
| 174 | |
| 175 | void test_private() { |
| 176 | int i; |
| 177 | // expected-error@+2 {{expected expression}} |
| 178 | // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 179 | #pragma omp target teams distribute private( |
| 180 | for (i = 0; i < 16; ++i) |
| 181 | ; |
| 182 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 183 | // expected-error@+1 2 {{expected expression}} |
| 184 | #pragma omp target teams distribute private(, |
| 185 | for (i = 0; i < 16; ++i) |
| 186 | ; |
| 187 | // expected-error@+1 2 {{expected expression}} |
| 188 | #pragma omp target teams distribute private(, ) |
| 189 | for (i = 0; i < 16; ++i) |
| 190 | ; |
| 191 | // expected-error@+1 {{expected expression}} |
| 192 | #pragma omp target teams distribute private() |
| 193 | for (i = 0; i < 16; ++i) |
| 194 | ; |
| 195 | // expected-error@+1 {{expected expression}} |
| 196 | #pragma omp target teams distribute private(int) |
| 197 | for (i = 0; i < 16; ++i) |
| 198 | ; |
| 199 | // expected-error@+1 {{expected variable name}} |
| 200 | #pragma omp target teams distribute private(0) |
| 201 | for (i = 0; i < 16; ++i) |
| 202 | ; |
| 203 | |
| 204 | int x, y, z; |
| 205 | #pragma omp target teams distribute private(x) |
| 206 | for (i = 0; i < 16; ++i) |
| 207 | ; |
| 208 | #pragma omp target teams distribute private(x, y) |
| 209 | for (i = 0; i < 16; ++i) |
| 210 | ; |
| 211 | #pragma omp target teams distribute private(x, y, z) |
| 212 | for (i = 0; i < 16; ++i) { |
| 213 | x = y * i + z; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | void test_lastprivate() { |
| 218 | int i; |
| 219 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 220 | // expected-error@+1 {{expected expression}} |
| 221 | #pragma omp target teams distribute lastprivate( |
| 222 | for (i = 0; i < 16; ++i) |
| 223 | ; |
| 224 | |
| 225 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 226 | // expected-error@+1 2 {{expected expression}} |
| 227 | #pragma omp target teams distribute lastprivate(, |
| 228 | for (i = 0; i < 16; ++i) |
| 229 | ; |
| 230 | // expected-error@+1 2 {{expected expression}} |
| 231 | #pragma omp target teams distribute lastprivate(, ) |
| 232 | for (i = 0; i < 16; ++i) |
| 233 | ; |
| 234 | // expected-error@+1 {{expected expression}} |
| 235 | #pragma omp target teams distribute lastprivate() |
| 236 | for (i = 0; i < 16; ++i) |
| 237 | ; |
| 238 | // expected-error@+1 {{expected expression}} |
| 239 | #pragma omp target teams distribute lastprivate(int) |
| 240 | for (i = 0; i < 16; ++i) |
| 241 | ; |
| 242 | // expected-error@+1 {{expected variable name}} |
| 243 | #pragma omp target teams distribute lastprivate(0) |
| 244 | for (i = 0; i < 16; ++i) |
| 245 | ; |
| 246 | |
| 247 | int x, y, z; |
| 248 | #pragma omp target teams distribute lastprivate(x) |
| 249 | for (i = 0; i < 16; ++i) |
| 250 | ; |
| 251 | #pragma omp target teams distribute lastprivate(x, y) |
| 252 | for (i = 0; i < 16; ++i) |
| 253 | ; |
| 254 | #pragma omp target teams distribute lastprivate(x, y, z) |
| 255 | for (i = 0; i < 16; ++i) |
| 256 | ; |
| 257 | } |
| 258 | |
| 259 | void test_firstprivate() { |
| 260 | int i; |
| 261 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 262 | // expected-error@+1 {{expected expression}} |
| 263 | #pragma omp target teams distribute firstprivate( |
| 264 | for (i = 0; i < 16; ++i) |
| 265 | ; |
| 266 | |
| 267 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 268 | // expected-error@+1 2 {{expected expression}} |
| 269 | #pragma omp target teams distribute firstprivate(, |
| 270 | for (i = 0; i < 16; ++i) |
| 271 | ; |
| 272 | // expected-error@+1 2 {{expected expression}} |
| 273 | #pragma omp target teams distribute firstprivate(, ) |
| 274 | for (i = 0; i < 16; ++i) |
| 275 | ; |
| 276 | // expected-error@+1 {{expected expression}} |
| 277 | #pragma omp target teams distribute firstprivate() |
| 278 | for (i = 0; i < 16; ++i) |
| 279 | ; |
| 280 | // expected-error@+1 {{expected expression}} |
| 281 | #pragma omp target teams distribute firstprivate(int) |
| 282 | for (i = 0; i < 16; ++i) |
| 283 | ; |
| 284 | // expected-error@+1 {{expected variable name}} |
| 285 | #pragma omp target teams distribute firstprivate(0) |
| 286 | for (i = 0; i < 16; ++i) |
| 287 | ; |
| 288 | |
| 289 | int x, y, z; |
| 290 | // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}} |
| 291 | #pragma omp target teams distribute lastprivate(x) firstprivate(x) |
| 292 | for (i = 0; i < 16; ++i) |
| 293 | ; |
| 294 | // expected-error@+1 2 {{lastprivate variable cannot be firstprivate}} expected-note@+1 2 {{defined as lastprivate}} |
| 295 | #pragma omp target teams distribute lastprivate(x, y) firstprivate(x, y) |
| 296 | for (i = 0; i < 16; ++i) |
| 297 | ; |
| 298 | // expected-error@+1 3 {{lastprivate variable cannot be firstprivate}} expected-note@+1 3 {{defined as lastprivate}} |
| 299 | #pragma omp target teams distribute lastprivate(x, y, z) firstprivate(x, y, z) |
| 300 | for (i = 0; i < 16; ++i) |
| 301 | ; |
| 302 | } |
| 303 | |
| 304 | void test_loop_messages() { |
| 305 | float a[100], b[100], c[100]; |
| 306 | // expected-error@+2 {{variable must be of integer or pointer type}} |
| 307 | #pragma omp target teams distribute |
| 308 | for (float fi = 0; fi < 10.0; fi++) { |
| 309 | c[(int)fi] = a[(int)fi] + b[(int)fi]; |
| 310 | } |
| 311 | // expected-error@+2 {{variable must be of integer or pointer type}} |
| 312 | #pragma omp target teams distribute |
| 313 | for (double fi = 0; fi < 10.0; fi++) { |
| 314 | c[(int)fi] = a[(int)fi] + b[(int)fi]; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | |