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