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