brintos

brintos / llvm-project-archived public Read only

0
0
Text · 20.5 KiB · 8cde648 Raw
482 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,omp51 -fopenmp -ferror-limit 150 -o - %s -Wuninitialized5// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized6// RUN: %clang_cc1 -verify=expected,omp51 -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 -o - %s -Wuninitialized11// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -std=c++98 -o - %s -Wuninitialized12// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -std=c++11 -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,omp51 -fopenmp-simd -ferror-limit 150 -o - %s -Wuninitialized18// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized19// RUN: %clang_cc1 -verify=expected,omp51 -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 -o - %s -Wuninitialized24// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -std=c++98 -o - %s -Wuninitialized25// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -std=c++11 -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 parallel31#pragma omp sections reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}32  {33    for (int i = 0; i < 10; ++i)34      ;35  }36}37 38void foo() {39}40 41bool foobool(int argc) {42  return argc;43}44 45void foobar(int &ref) {46#pragma omp parallel47#pragma omp sections reduction(+:ref)48  {49    foo();50  }51}52 53struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}54extern S1 a;55class S2 {56  mutable int a;57  S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}58 59public: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};65const float S2::S2sc = 0;66S2 b;                     // expected-note 3 {{'b' defined here}}67const S2 ba[5];           // expected-note 2 {{'ba' defined here}}68class S3 {69  int a;70 71public:72  int b;73  S3() : a(0) {}74  S3(const S3 &s3) : a(s3.a) {}75  S3 operator+(const S3 &arg1) { return arg1; }76};77int operator+(const S3 &arg1, const S3 &arg2) { return 5; }78S3 c;               // expected-note 3 {{'c' defined here}}79const S3 ca[5];     // expected-note 2 {{'ca' defined here}}80extern const int f; // expected-note 4 {{'f' declared here}}81class 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 87public:88  S4(int v) : a(v) {}89};90S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }91class 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 97public:98  S5(int v) : a(v) {}99};100class 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 later102// expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}103#endif104  int a;105 106public:107  S6() : a(6) {}108  operator int() { return 6; }109} o;110 111S3 h, k;112#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}113 114template <class T>       // expected-note {{declared here}}115T 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, z;120  T &j = i;                // expected-note 4 {{'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];       // expected-note 2 {{'q' defined here}}124  T fl;125#pragma omp parallel126#pragma omp sections reduction // expected-error {{expected '(' after 'reduction'}}127  {128    foo();129  }130#pragma omp parallel131#pragma omp sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp sections' are ignored}}132  {133    foo();134  }135#pragma omp parallel136#pragma omp sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}137  {138    foo();139  }140#pragma omp parallel141#pragma omp sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}142  {143    foo();144  }145#pragma omp parallel146#pragma omp sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}147  {148    foo();149  }150#pragma omp parallel151#pragma omp sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}152  {153    foo();154  }155#pragma omp parallel156#pragma omp sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}157  {158    foo();159  }160#pragma omp parallel161#pragma omp sections reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}162  {163    foo();164  }165#pragma omp parallel166#pragma omp sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}167  {168    foo();169  }170#pragma omp parallel171#pragma omp sections reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}172  {173    foo();174  }175#pragma omp parallel176#pragma omp sections 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'}} omp51-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} omp51-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'}}177  {178    foo();179  }180#pragma omp parallel181#pragma omp sections 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 '('}}182  {183    foo();184  }185#pragma omp parallel186#pragma omp sections reduction(^ : T) // expected-error {{'T' does not refer to a value}}187  {188    foo();189  }190#pragma omp parallel191#pragma omp sections reduction(+ : 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'}}192  {193    foo();194  }195#pragma omp parallel196#pragma omp sections 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}}197  {198    foo();199  }200#pragma omp parallel201#pragma omp sections reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}202  {203    foo();204  }205#pragma omp parallel206#pragma omp sections reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}207  {208    foo();209  }210#pragma omp parallel211#pragma omp sections reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}212  {213    foo();214  }215#pragma omp parallel216#pragma omp sections 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}}217  {218    foo();219  }220#pragma omp parallel221#pragma omp sections reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}222  {223    foo();224  }225#pragma omp parallel226#pragma omp sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}227  {228    foo();229  }230#pragma omp parallel231#pragma omp sections reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}232  {233    foo();234  }235#pragma omp parallel236#pragma omp sections reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}237  {238    foo();239  }240#pragma omp parallel241#pragma omp sections reduction(+ : o, z) // expected-error 2 {{no viable overloaded '='}}242  {243    foo();244  }245#pragma omp parallel246#pragma omp sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}247  {248    foo();249  }250#pragma omp parallel private(k)251#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}252  {253    foo();254  }255#pragma omp parallel256#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}257  {258    foo();259  }260#pragma omp parallel261#pragma omp sections reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}262  {263    foo();264  }265#pragma omp parallel shared(i)266#pragma omp parallel reduction(min : i)267#pragma omp sections reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}268  {269    foo();270  }271#if defined(_OPENMP) && (_OPENMP <= 202111)272#pragma omp parallel private(fl)       // expected-note 2 {{defined as private}}273#pragma omp sections reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}274  {275    foo();276  }277#pragma omp parallel reduction(* : fl) // expected-note 2 {{defined as reduction}}278#pragma omp sections reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}279  {280    foo();281  }282#endif283 284  return T();285}286 287namespace A {288double x;289#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}290}291namespace B {292using A::x;293}294 295int main(int argc, char **argv) {296  const int d = 5;       // expected-note 2 {{'d' defined here}}297  const int da[5] = {0}; // expected-note {{'da' defined here}}298  int qa[5] = {0};299  S4 e(4);300  S5 g(5);301  int i, z;302  int &j = i;           // expected-note 2 {{'j' defined here}}303  S3 &p = k;            // expected-note 2 {{'p' defined here}}304  const int &r = da[i]; // expected-note {{'r' defined here}}305  int &q = qa[i];       // expected-note {{'q' defined here}}306  float fl;307#pragma omp parallel308#pragma omp sections reduction // expected-error {{expected '(' after 'reduction'}}309  {310    foo();311  }312#pragma omp parallel313#pragma omp sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp sections' are ignored}}314  {315    foo();316  }317#pragma omp parallel318#pragma omp sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}319  {320    foo();321  }322#pragma omp parallel323#pragma omp sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}324  {325    foo();326  }327#pragma omp parallel328#pragma omp sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}329  {330    foo();331  }332#pragma omp parallel333#pragma omp sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}334  {335    foo();336  }337#pragma omp parallel338#pragma omp sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}339  {340    foo();341  }342#pragma omp parallel343#pragma omp sections reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} omp45-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} omp51-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'}}344  {345    foo();346  }347#pragma omp parallel348#pragma omp sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}349  {350    foo();351  }352#pragma omp parallel353#pragma omp sections reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}354  {355    foo();356  }357#pragma omp parallel358#pragma omp sections reduction(~ : argc) // expected-error {{expected unqualified-id}}359  {360    foo();361  }362#pragma omp parallel363#pragma omp sections reduction(&& : argc, z)364  {365    foo();366  }367#pragma omp parallel368#pragma omp sections reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}369  {370    foo();371  }372#pragma omp parallel373#pragma omp sections 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'}}374  {375    foo();376  }377#pragma omp parallel378#pragma omp sections 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}}379  {380    foo();381  }382#pragma omp parallel383#pragma omp sections reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}384  {385    foo();386  }387#pragma omp parallel388#pragma omp sections reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}389  {390    foo();391  }392#pragma omp parallel393#pragma omp sections reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}394  {395    foo();396  }397#pragma omp parallel398#pragma omp sections reduction(- : da) // expected-error {{const-qualified variable cannot be reduction}} omp52-warning {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}399  {400    foo();401  }402#pragma omp parallel403#pragma omp sections reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}404  {405    foo();406  }407#pragma omp parallel408#pragma omp sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}409  {410    foo();411  }412#pragma omp parallel413#pragma omp sections reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}414  {415    foo();416  }417#pragma omp parallel418#pragma omp sections 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')}}419  {420    foo();421  }422#pragma omp parallel423#pragma omp sections reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}424  {425    foo();426  }427#pragma omp parallel428#pragma omp sections reduction(+ : o) // expected-error {{no viable overloaded '='}}429  {430    foo();431  }432#pragma omp parallel433#pragma omp sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}434  {435    foo();436  }437#pragma omp parallel private(k)438#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}439  {440    foo();441  }442#pragma omp parallel443#pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}444  {445    foo();446  }447#pragma omp parallel448#pragma omp sections reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}449  {450    foo();451  }452#pragma omp parallel shared(i)453#pragma omp parallel reduction(min : i)454#pragma omp sections reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}455  {456    foo();457  }458#if defined(_OPENMP) && (_OPENMP <= 202111)459#pragma omp parallel private(fl)       // expected-note {{defined as private}}460#pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}}461  {462    foo();463  }464#pragma omp parallel reduction(* : fl) // expected-note {{defined as reduction}}465#pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}}466  {467    foo();468  }469#endif470  static int m;471#pragma omp sections reduction(+ : m) // OK472  {473    foo();474  }475#pragma omp sections reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}476  {477    foo();478  }479 480  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}}481}482