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