brintos

brintos / llvm-project-archived public Read only

0
0
Text · 21.4 KiB · 2399ce8 Raw
285 lines · cpp
1// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 %s -Wuninitialized2// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++98 %s -Wuninitialized3// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++11 %s -Wuninitialized4// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp %s -Wuninitialized5// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -std=c++98 %s -Wuninitialized6// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -std=c++11 %s -Wuninitialized7// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 %s -Wuninitialized8// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -std=c++98 %s -Wuninitialized9// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -std=c++11 %s -Wuninitialized10// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 %s -Wuninitialized11// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -std=c++98 %s -Wuninitialized12// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -std=c++11 %s -Wuninitialized13 14// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized15// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++98 %s -Wuninitialized16// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++11 %s -Wuninitialized17// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd %s -Wuninitialized18// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -std=c++98 %s -Wuninitialized19// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -std=c++11 %s -Wuninitialized20// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 %s -Wuninitialized21// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -std=c++98 %s -Wuninitialized22// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -std=c++11 %s -Wuninitialized23// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 %s -Wuninitialized24// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -std=c++98 %s -Wuninitialized25// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -std=c++11 %s -Wuninitialized26 27#pragma omp requires dynamic_allocators28typedef void **omp_allocator_handle_t;29extern const omp_allocator_handle_t omp_null_allocator;30extern const omp_allocator_handle_t omp_default_mem_alloc;31extern const omp_allocator_handle_t omp_large_cap_mem_alloc;32extern const omp_allocator_handle_t omp_const_mem_alloc;33extern const omp_allocator_handle_t omp_high_bw_mem_alloc;34extern const omp_allocator_handle_t omp_low_lat_mem_alloc;35extern const omp_allocator_handle_t omp_cgroup_mem_alloc;36extern const omp_allocator_handle_t omp_pteam_mem_alloc;37extern const omp_allocator_handle_t omp_thread_mem_alloc;38 39void xxx(int argc) {40  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}41#pragma omp target teams distribute simd reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}42  for (int i = 0; i < 10; ++i)43    ;44}45 46void foo() {47}48 49bool foobool(int argc) {50  return argc;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 target teams distribute simd reduction // expected-error {{expected '(' after 'reduction'}}126  for (int j=0; j<100; j++) foo();127#pragma omp target teams distribute simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}128  for (int j=0; j<100; j++) foo();129#pragma omp target teams distribute simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}130  for (int j=0; j<100; j++) foo();131#pragma omp target teams distribute simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}132  for (int j=0; j<100; j++) foo();133#pragma omp target teams distribute simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}134  for (int j=0; j<100; j++) foo();135#pragma omp target teams distribute simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}136  for (int j=0; j<100; j++) foo();137#pragma omp target teams distribute simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}138  for (int j=0; j<100; j++) foo();139#pragma omp target teams distribute simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}140  for (int j=0; j<100; j++) foo();141#pragma omp target teams distribute 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')}}142  for (int j=0; j<100; j++) foo();143#pragma omp target teams distribute simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}144  for (int j=0; j<100; j++) foo();145#pragma omp target teams distribute simd 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'}}146  for (int j=0; j<100; j++) foo();147#pragma omp target teams distribute simd 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 '('}}148  for (int j=0; j<100; j++) foo();149#pragma omp target teams distribute simd reduction(^ : T) // expected-error {{'T' does not refer to a value}}150  for (int j=0; j<100; j++) foo();151#pragma omp target teams distribute simd 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'}}152  for (int j=0; j<100; j++) foo();153#pragma omp target teams distribute simd reduction(min : z, 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}}154  for (int j=0; j<100; j++) foo();155#pragma omp target teams distribute simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}156  for (int j=0; j<100; j++) foo();157#pragma omp target teams distribute simd reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}158  for (int j=0; j<100; j++) foo();159#pragma omp target teams distribute simd reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}160  for (int j=0; j<100; j++) foo();161#pragma omp target teams distribute simd 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}}162  for (int j=0; j<100; j++) foo();163#pragma omp target teams distribute simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}164  for (int j=0; j<100; j++) foo();165#pragma omp target teams distribute simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}166  for (int j=0; j<100; j++) foo();167#pragma omp target teams distribute simd reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}168  for (int j=0; j<100; j++) foo();169#pragma omp target teams distribute simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}170  for (int j=0; j<100; j++) foo();171#pragma omp target teams distribute simd reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}172  for (int j=0; j<100; j++) foo();173#pragma omp target teams distribute simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}174  for (int j=0; j<100; j++) foo();175#pragma omp parallel private(k)176#pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}177  for (int j=0; j<100; j++) foo();178#pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}179  for (int j=0; j<100; j++) foo();180#pragma omp target teams distribute simd reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}181  for (int j=0; j<100; j++) foo();182#pragma omp parallel shared(i)183#pragma omp parallel reduction(min : i)184#pragma omp target teams distribute simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}185  for (int j=0; j<100; j++) foo();186#pragma omp target teams distribute simd reduction(+ : fl) allocate(omp_thread_mem_alloc: fl) // expected-warning 2 {{allocator with the 'thread' trait access has unspecified behavior on 'target teams distribute simd' directive}}187    for (int j=0; j<100; j++) foo();188 189  return T();190}191 192namespace A {193double x;194#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}195}196namespace B {197using A::x;198}199 200int main(int argc, char **argv) {201  const int d = 5;       // expected-note 2 {{'d' defined here}}202  const int da[5] = {0}; // expected-note {{'da' defined here}}203  int qa[5] = {0};204  S4 e(4);205  S5 g(5);206  int i, z;207  int &j = i;                  // expected-note 2 {{'j' defined here}}208  S3 &p = k;                   // expected-note 2 {{'p' defined here}}209  const int &r = da[i];        // expected-note {{'r' defined here}}210  int &q = qa[i];              // expected-note {{'q' defined here}}211  float fl;212#pragma omp target teams distribute simd reduction // expected-error {{expected '(' after 'reduction'}}213  for (int j=0; j<100; j++) foo();214#pragma omp target teams distribute simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}215  for (int j=0; j<100; j++) foo();216#pragma omp target teams distribute simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}217  for (int j=0; j<100; j++) foo();218#pragma omp target teams distribute simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}219  for (int j=0; j<100; j++) foo();220#pragma omp target teams distribute simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}221  for (int j=0; j<100; j++) foo();222#pragma omp target teams distribute simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}223  for (int j=0; j<100; j++) foo();224#pragma omp target teams distribute simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}225  for (int j=0; j<100; j++) foo();226#pragma omp target teams distribute simd 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'}}227  for (int j=0; j<100; j++) foo();228#pragma omp target teams distribute simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}229  for (int j=0; j<100; j++) foo();230#pragma omp target teams distribute simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}231  for (int j=0; j<100; j++) foo();232#pragma omp target teams distribute simd reduction(~ : argc) // expected-error {{expected unqualified-id}}233  for (int j=0; j<100; j++) foo();234#pragma omp target teams distribute simd reduction(&& : argc)235  for (int j=0; j<100; j++) foo();236#pragma omp target teams distribute simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}237  for (int j=0; j<100; j++) foo();238#pragma omp target teams distribute simd 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'}}239  for (int j=0; j<100; j++) foo();240#pragma omp target teams distribute 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 variable cannot be reduction}}241  for (int j=0; j<100; j++) foo();242#pragma omp target teams distribute simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}243  for (int j=0; j<100; j++) foo();244#pragma omp target teams distribute simd reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}245  for (int j=0; j<100; j++) foo();246#pragma omp target teams distribute simd reduction(* : ca, z) // expected-error {{const-qualified variable cannot be reduction}}247  for (int j=0; j<100; j++) foo();248#pragma omp target teams distribute simd reduction(- : da) // expected-error {{const-qualified variable cannot be reduction}} omp52-warning {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}249  for (int j=0; j<100; j++) foo();250#pragma omp target teams distribute simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}251  for (int j=0; j<100; j++) foo();252#pragma omp target teams distribute simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}253  for (int j=0; j<100; j++) foo();254#pragma omp target teams distribute simd reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}255  for (int j=0; j<100; j++) foo();256#pragma omp target teams distribute simd 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')}}257  for (int j=0; j<100; j++) foo();258#pragma omp target teams distribute simd reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}259  for (int j=0; j<100; j++) foo();260#pragma omp target teams distribute simd reduction(+ : o) // expected-error {{no viable overloaded '='}}261  for (int j=0; j<100; j++) foo();262#pragma omp target teams distribute simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}263  for (int j=0; j<100; j++) foo();264#pragma omp parallel private(k)265#pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}266  for (int j=0; j<100; j++) foo();267#pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}268  for (int j=0; j<100; j++) foo();269#pragma omp target teams distribute simd reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}270  for (int j=0; j<100; j++) foo();271#pragma omp parallel shared(i)272#pragma omp parallel reduction(min : i)273#pragma omp target teams distribute simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}274  for (int j=0; j<100; j++) foo();275#pragma omp target teams distribute simd reduction(+ : fl)276    for (int j=0; j<100; j++) foo();277  static int m;278#pragma omp target teams distribute simd reduction(+ : m) // OK279  for (int j=0; j<100; j++) foo();280#pragma omp target teams distribute simd reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}} omp51-error {{'reduction' clause with 'task' modifier allowed only on non-simd parallel or worksharing constructs}} omp52-error {{'reduction' clause with 'task' modifier allowed only on non-simd parallel or worksharing constructs}} omp60-error {{'reduction' clause with 'task' modifier allowed only on non-simd parallel or worksharing constructs}}281  for (int j=0; j<100; j++) foo();282 283  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}}284}285