1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s 2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 -ferror-limit 150 -o - %s 3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 150 -o - %s 4 5 void foo() { 6 } 7 8 bool foobool(int argc) { 9 return argc; 10 } 11 12 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}} 13 extern S1 a; 14 class S2 { 15 mutable int a; 16 S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}} 17 18 public: 19 S2() : a(0) {} 20 S2(S2 &s2) : a(s2.a) {} 21 static float S2s; // expected-note 2 {{static data member is predetermined as shared}} 22 static const float S2sc; 23 }; 24 const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}} 25 S2 b; // expected-note 3 {{'b' defined here}} 26 const S2 ba[5]; // expected-note 2 {{'ba' defined here}} 27 class S3 { 28 int a; 29 30 public: 31 int b; 32 S3() : a(0) {} 33 S3(const S3 &s3) : a(s3.a) {} 34 S3 operator+(const S3 &arg1) { return arg1; } 35 }; 36 int operator+(const S3 &arg1, const S3 &arg2) { return 5; } 37 S3 c; // expected-note 3 {{'c' defined here}} 38 const S3 ca[5]; // expected-note 2 {{'ca' defined here}} 39 extern const int f; // expected-note 4 {{'f' declared here}} 40 class S4 { 41 int a; 42 S4(); // expected-note {{implicitly declared private here}} 43 S4(const S4 &s4); 44 S4 &operator+(const S4 &arg) { return (*this); } 45 46 public: 47 S4(int v) : a(v) {} 48 }; 49 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; } 50 class S5 { 51 int a; 52 S5() : a(0) {} // expected-note {{implicitly declared private here}} 53 S5(const S5 &s5) : a(s5.a) {} 54 S5 &operator+(const S5 &arg); 55 56 public: 57 S5(int v) : a(v) {} 58 }; 59 class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}} 60 #if __cplusplus >= 201103L // C++11 or later 61 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}} 62 #endif 63 int a; 64 65 public: 66 S6() : a(6) {} 67 operator int() { return 6; } 68 } o; 69 70 S3 h, k; 71 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 72 73 template <class T> // expected-note {{declared here}} 74 T tmain(T argc) { 75 const T d = T(); // expected-note 4 {{'d' defined here}} 76 const T da[5] = {T()}; // expected-note 2 {{'da' defined here}} 77 T qa[5] = {T()}; 78 T i; 79 T &j = i; // expected-note 4 {{'j' defined here}} 80 S3 &p = k; // expected-note 2 {{'p' defined here}} 81 const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}} 82 T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}} 83 T fl; 84 #pragma omp target 85 #pragma omp teams 86 #pragma omp distribute parallel for simd reduction // expected-error {{expected '(' after 'reduction'}} 87 for (int i = 0; i < 10; ++i) 88 foo(); 89 #pragma omp target 90 #pragma omp teams 91 #pragma omp distribute parallel for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}} 92 for (int i = 0; i < 10; ++i) 93 foo(); 94 #pragma omp target 95 #pragma omp teams 96 #pragma omp distribute parallel for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} 97 for (int i = 0; i < 10; ++i) 98 foo(); 99 #pragma omp target 100 #pragma omp teams 101 #pragma omp distribute parallel for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 102 for (int i = 0; i < 10; ++i) 103 foo(); 104 #pragma omp target 105 #pragma omp teams 106 #pragma omp distribute parallel for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} 107 for (int i = 0; i < 10; ++i) 108 foo(); 109 #pragma omp target 110 #pragma omp teams 111 #pragma omp distribute parallel for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} 112 for (int i = 0; i < 10; ++i) 113 foo(); 114 #pragma omp target 115 #pragma omp teams 116 #pragma omp distribute parallel for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} 117 for (int i = 0; i < 10; ++i) 118 foo(); 119 #pragma omp target 120 #pragma omp teams 121 #pragma omp distribute parallel for simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} 122 for (int i = 0; i < 10; ++i) 123 foo(); 124 #pragma omp target 125 #pragma omp teams 126 #pragma omp distribute parallel for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} 127 for (int i = 0; i < 10; ++i) 128 foo(); 129 #pragma omp target 130 #pragma omp teams 131 #pragma omp distribute parallel for simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}} 132 for (int i = 0; i < 10; ++i) 133 foo(); 134 #pragma omp target 135 #pragma omp teams 136 #pragma omp distribute parallel for simd reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} 137 for (int i = 0; i < 10; ++i) 138 foo(); 139 #pragma omp target 140 #pragma omp teams 141 #pragma omp distribute parallel for simd reduction(&& : argc) 142 for (int i = 0; i < 10; ++i) 143 foo(); 144 #pragma omp target 145 #pragma omp teams 146 #pragma omp distribute parallel for simd reduction(^ : T) // expected-error {{'T' does not refer to a value}} 147 for (int i = 0; i < 10; ++i) 148 foo(); 149 #pragma omp target 150 #pragma omp teams 151 #pragma omp distribute parallel for simd reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified list item cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}} 152 for (int i = 0; i < 10; ++i) 153 foo(); 154 #pragma omp target 155 #pragma omp teams 156 #pragma omp distribute parallel for simd reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified list item cannot be reduction}} 157 for (int i = 0; i < 10; ++i) 158 foo(); 159 #pragma omp target 160 #pragma omp teams 161 #pragma omp distribute parallel for simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} 162 for (int i = 0; i < 10; ++i) 163 foo(); 164 #pragma omp target 165 #pragma omp teams 166 #pragma omp distribute parallel for simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} 167 for (int i = 0; i < 10; ++i) 168 foo(); 169 #pragma omp target 170 #pragma omp teams 171 #pragma omp distribute parallel for simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} 172 for (int i = 0; i < 10; ++i) 173 foo(); 174 #pragma omp target 175 #pragma omp teams 176 #pragma omp distribute parallel for simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}} 177 for (int i = 0; i < 10; ++i) 178 foo(); 179 #pragma omp target 180 #pragma omp teams 181 #pragma omp distribute parallel for simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} 182 for (int i = 0; i < 10; ++i) 183 foo(); 184 #pragma omp target 185 #pragma omp teams 186 #pragma omp distribute parallel for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} 187 for (int i = 0; i < 10; ++i) 188 foo(); 189 #pragma omp target 190 #pragma omp teams 191 #pragma omp distribute parallel for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} 192 for (int i = 0; i < 10; ++i) 193 foo(); 194 #pragma omp target 195 #pragma omp teams 196 #pragma omp distribute parallel for simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} 197 for (int i = 0; i < 10; ++i) 198 foo(); 199 #pragma omp target 200 #pragma omp teams 201 #pragma omp distribute parallel for simd reduction(+ : o) // expected-error 2 {{no viable overloaded '='}} 202 for (int i = 0; i < 10; ++i) 203 foo(); 204 #pragma omp target 205 #pragma omp teams 206 #pragma omp distribute parallel for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} 207 for (int i = 0; i < 10; ++i) 208 foo(); 209 #pragma omp parallel private(k) 210 #pragma omp target 211 #pragma omp teams 212 #pragma omp distribute parallel for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} 213 for (int i = 0; i < 10; ++i) 214 foo(); 215 #pragma omp target 216 #pragma omp teams 217 #pragma omp distribute parallel for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}} 218 for (int i = 0; i < 10; ++i) 219 foo(); 220 #pragma omp target 221 #pragma omp teams 222 #pragma omp distribute parallel for simd reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}} 223 for (int i = 0; i < 10; ++i) 224 foo(); 225 #pragma omp parallel shared(i) 226 #pragma omp parallel reduction(min : i) 227 #pragma omp target 228 #pragma omp teams 229 #pragma omp distribute parallel for simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} 230 for (int i = 0; i < 10; ++i) 231 foo(); 232 #pragma omp parallel private(fl) 233 #pragma omp target 234 #pragma omp teams 235 #pragma omp distribute parallel for simd reduction(+ : fl) 236 for (int i = 0; i < 10; ++i) 237 foo(); 238 #pragma omp parallel reduction(* : fl) 239 #pragma omp target 240 #pragma omp teams 241 #pragma omp distribute parallel for simd reduction(+ : fl) 242 for (int i = 0; i < 10; ++i) 243 foo(); 244 245 return T(); 246 } 247 248 namespace A { 249 double x; 250 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 251 } 252 namespace B { 253 using A::x; 254 } 255 256 int main(int argc, char **argv) { 257 const int d = 5; // expected-note 2 {{'d' defined here}} 258 const int da[5] = {0}; // expected-note {{'da' defined here}} 259 int qa[5] = {0}; 260 S4 e(4); 261 S5 g(5); 262 int i; 263 int &j = i; // expected-note 2 {{'j' defined here}} 264 S3 &p = k; // expected-note 2 {{'p' defined here}} 265 const int &r = da[i]; // expected-note {{'r' defined here}} 266 int &q = qa[i]; // expected-note {{'q' defined here}} 267 float fl; 268 #pragma omp target 269 #pragma omp teams 270 #pragma omp distribute parallel for simd reduction // expected-error {{expected '(' after 'reduction'}} 271 for (int i = 0; i < 10; ++i) 272 foo(); 273 #pragma omp target 274 #pragma omp teams 275 #pragma omp distribute parallel for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}} 276 for (int i = 0; i < 10; ++i) 277 foo(); 278 #pragma omp target 279 #pragma omp teams 280 #pragma omp distribute parallel for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} 281 for (int i = 0; i < 10; ++i) 282 foo(); 283 #pragma omp target 284 #pragma omp teams 285 #pragma omp distribute parallel for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 286 for (int i = 0; i < 10; ++i) 287 foo(); 288 #pragma omp target 289 #pragma omp teams 290 #pragma omp distribute parallel for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} 291 for (int i = 0; i < 10; ++i) 292 foo(); 293 #pragma omp target 294 #pragma omp teams 295 #pragma omp distribute parallel for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} 296 for (int i = 0; i < 10; ++i) 297 foo(); 298 #pragma omp target 299 #pragma omp teams 300 #pragma omp distribute parallel for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} 301 for (int i = 0; i < 10; ++i) 302 foo(); 303 #pragma omp target 304 #pragma omp teams 305 #pragma omp distribute parallel for simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} 306 for (int i = 0; i < 10; ++i) 307 foo(); 308 #pragma omp target 309 #pragma omp teams 310 #pragma omp distribute parallel for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 311 for (int i = 0; i < 10; ++i) 312 foo(); 313 #pragma omp target 314 #pragma omp teams 315 #pragma omp distribute parallel for simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}} 316 for (int i = 0; i < 10; ++i) 317 foo(); 318 #pragma omp target 319 #pragma omp teams 320 #pragma omp distribute parallel for simd reduction(~ : argc) // expected-error {{expected unqualified-id}} 321 for (int i = 0; i < 10; ++i) 322 foo(); 323 #pragma omp target 324 #pragma omp teams 325 #pragma omp distribute parallel for simd reduction(&& : argc) 326 for (int i = 0; i < 10; ++i) 327 foo(); 328 #pragma omp target 329 #pragma omp teams 330 #pragma omp distribute parallel for simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}} 331 for (int i = 0; i < 10; ++i) 332 foo(); 333 #pragma omp target 334 #pragma omp teams 335 #pragma omp distribute parallel for simd reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified list item cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}} 336 for (int i = 0; i < 10; ++i) 337 foo(); 338 #pragma omp target 339 #pragma omp teams 340 #pragma omp distribute parallel for simd reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified list item cannot be reduction}} 341 for (int i = 0; i < 10; ++i) 342 foo(); 343 #pragma omp target 344 #pragma omp teams 345 #pragma omp distribute parallel for simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} 346 for (int i = 0; i < 10; ++i) 347 foo(); 348 #pragma omp target 349 #pragma omp teams 350 #pragma omp distribute parallel for simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} 351 for (int i = 0; i < 10; ++i) 352 foo(); 353 #pragma omp target 354 #pragma omp teams 355 #pragma omp distribute parallel for simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} 356 for (int i = 0; i < 10; ++i) 357 foo(); 358 #pragma omp target 359 #pragma omp teams 360 #pragma omp distribute parallel for simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} 361 for (int i = 0; i < 10; ++i) 362 foo(); 363 #pragma omp target 364 #pragma omp teams 365 #pragma omp distribute parallel for simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} 366 for (int i = 0; i < 10; ++i) 367 foo(); 368 #pragma omp target 369 #pragma omp teams 370 #pragma omp distribute parallel for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} 371 for (int i = 0; i < 10; ++i) 372 foo(); 373 #pragma omp target 374 #pragma omp teams 375 #pragma omp distribute parallel for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} 376 for (int i = 0; i < 10; ++i) 377 foo(); 378 #pragma omp target 379 #pragma omp teams 380 #pragma omp distribute parallel for simd reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}} 381 for (int i = 0; i < 10; ++i) 382 foo(); 383 #pragma omp target 384 #pragma omp teams 385 #pragma omp distribute parallel for simd reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}} 386 for (int i = 0; i < 10; ++i) 387 foo(); 388 #pragma omp target 389 #pragma omp teams 390 #pragma omp distribute parallel for simd reduction(+ : o) // expected-error {{no viable overloaded '='}} 391 for (int i = 0; i < 10; ++i) 392 foo(); 393 #pragma omp target 394 #pragma omp teams 395 #pragma omp distribute parallel for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} 396 for (int i = 0; i < 10; ++i) 397 foo(); 398 #pragma omp parallel private(k) 399 #pragma omp target 400 #pragma omp teams 401 #pragma omp distribute parallel for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} 402 for (int i = 0; i < 10; ++i) 403 foo(); 404 #pragma omp target 405 #pragma omp teams 406 #pragma omp distribute parallel for simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} 407 for (int i = 0; i < 10; ++i) 408 foo(); 409 #pragma omp target 410 #pragma omp teams 411 #pragma omp distribute parallel for simd reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}} 412 for (int i = 0; i < 10; ++i) 413 foo(); 414 #pragma omp parallel shared(i) 415 #pragma omp parallel reduction(min : i) 416 #pragma omp target 417 #pragma omp teams 418 #pragma omp distribute parallel for simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} 419 for (int i = 0; i < 10; ++i) 420 foo(); 421 #pragma omp parallel private(fl) 422 #pragma omp target 423 #pragma omp teams 424 #pragma omp distribute parallel for simd reduction(+ : fl) 425 for (int i = 0; i < 10; ++i) 426 foo(); 427 #pragma omp parallel reduction(* : fl) 428 #pragma omp target 429 #pragma omp teams 430 #pragma omp distribute parallel for simd reduction(+ : fl) 431 for (int i = 0; i < 10; ++i) 432 foo(); 433 static int m; 434 #pragma omp target 435 #pragma omp teams 436 #pragma omp distribute parallel for simd reduction(+ : m) // OK 437 for (int i = 0; i < 10; ++i) 438 m++; 439 440 return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}} 441 } 442