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