brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.7 KiB · 2eafb36 Raw
219 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized4 5void xxx(int argc) {6  int fp, fp1; // expected-note {{initialize the variable 'fp' to silence this warning}} expected-note {{initialize the variable 'fp1' to silence this warning}}7#pragma omp target firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}8  for (int i = 0; i < 10; ++i)9    ++fp1; // expected-warning {{variable 'fp1' is uninitialized when used here}}10}11 12typedef void **omp_allocator_handle_t;13extern const omp_allocator_handle_t omp_null_allocator;14extern const omp_allocator_handle_t omp_default_mem_alloc;15extern const omp_allocator_handle_t omp_large_cap_mem_alloc;16extern const omp_allocator_handle_t omp_const_mem_alloc;17extern const omp_allocator_handle_t omp_high_bw_mem_alloc;18extern const omp_allocator_handle_t omp_low_lat_mem_alloc;19extern const omp_allocator_handle_t omp_cgroup_mem_alloc;20extern const omp_allocator_handle_t omp_pteam_mem_alloc;21extern const omp_allocator_handle_t omp_thread_mem_alloc;22 23struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}24extern S1 a;25class S2 {26  mutable int a;27 28public:29  S2() : a(0) {}30};31const S2 b;32const S2 ba[5];33class S3 {34  int a;35 36public:37  S3() : a(0) {}38};39const S3 ca[5];40class S4 {41  int a;42  S4();43 44public:45  S4(int v) : a(v) {46#pragma omp target firstprivate(a) firstprivate(this->a)47    for (int k = 0; k < v; ++k)48      ++this->a;49  }50};51class S5 {52  int a;53  S5() : a(0) {}54 55public:56  S5(int v) : a(v) {}57  S5 &operator=(S5 &s) {58#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}}59    for (int k = 0; k < s.a; ++k) // expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}60      ++s.a;61    return *this;62  }63};64 65template <typename T>66class S6 {67public:68  T a;69 70  S6() : a(0) {}71  S6(T v) : a(v) {72#pragma omp target firstprivate(a) firstprivate(this->a)73    for (int k = 0; k < v; ++k)74      ++this->a;75  }76  S6 &operator=(S6 &s) {77#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}}78    for (int k = 0; k < s.a; ++k)79      ++s.a;80    return *this;81  }82};83 84template <typename T>85class S7 : public T {86  T a;87  S7() : a(0) {}88 89public:90  S7(T v) : a(v) {91#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(T::a)92    for (int k = 0; k < a.a; ++k)93      ++this->a.a;94  }95  S7 &operator=(S7 &s) {96#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) firstprivate(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}97    for (int k = 0; k < s.a.a; ++k)98      ++s.a.a;99    return *this;100  }101};102 103S3 h;104#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}105 106template <class I, class C>107int foomain(I argc, C **argv) {108  I e(4);109  I g(5);110  int i, z;111  int &j = i;112#pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}}113{}114#pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}115{}116#pragma omp target firstprivate() // expected-error {{expected expression}}117{}118#pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}119{}120#pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}121{}122#pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}123{}124#pragma omp target firstprivate(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 '('}}125{}126#pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}}127{}128#pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}129{}130#pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}}131{}132#pragma omp target firstprivate(e, g) allocate(omp_thread_mem_alloc: e) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target' directive}} expected-error {{allocator must be specified in the 'uses_allocators' clause}}133{}134#pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}135{}136#pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}137#pragma omp parallel138  {139    int v = 0;140    int i;141  }142#pragma omp parallel shared(i, z)143#pragma omp parallel firstprivate(i, z)144#pragma omp target firstprivate(j)145{}146#pragma omp target firstprivate(i)147  {}148  return 0;149}150 151void bar(S4 a[2]) {152#pragma omp parallel153#pragma omp target firstprivate(a)154  {}155}156 157namespace A {158double x;159#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}160}161namespace B {162using A::x;163}164 165int main(int argc, char **argv) {166  S4 e(4);167  S5 g(5);168  S6<float> s6(0.0) , s6_0(1.0);169  S7<S6<float> > s7(0.0) , s7_0(1.0);170  int i, z;171  int &j = i;172#pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}}173{}174#pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}175{}176#pragma omp target firstprivate() // expected-error {{expected expression}}177{}178#pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}179{}180#pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}181{}182#pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}183{}184#pragma omp target firstprivate(argc, z)185{}186#pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}}187{}188#pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}189{}190#pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}}191{}192#pragma omp target firstprivate(e, g)193{}194#pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}195{}196#pragma omp target firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}197{}198#pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}199#pragma omp parallel200  {201    int i;202  }203#pragma omp parallel shared(i)204#pragma omp parallel firstprivate(i)205#pragma omp target firstprivate(j)206{}207#pragma omp target firstprivate(i)208  {}209  static int si;210#pragma omp target firstprivate(si) // OK211  {}212#pragma omp target map(i) firstprivate(i) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}}213  {}214  s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}215  s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float>>::operator=' requested here}}216  return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}217}218 219