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