brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.4 KiB · 6662a70 Raw
282 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized4 5typedef void **omp_allocator_handle_t;6extern const omp_allocator_handle_t omp_null_allocator;7extern const omp_allocator_handle_t omp_default_mem_alloc;8extern const omp_allocator_handle_t omp_large_cap_mem_alloc;9extern const omp_allocator_handle_t omp_const_mem_alloc;10extern const omp_allocator_handle_t omp_high_bw_mem_alloc;11extern const omp_allocator_handle_t omp_low_lat_mem_alloc;12extern const omp_allocator_handle_t omp_cgroup_mem_alloc;13extern const omp_allocator_handle_t omp_pteam_mem_alloc;14extern const omp_allocator_handle_t omp_thread_mem_alloc;15 16void foo() {17}18 19bool foobool(int argc) {20  return argc;21}22 23void xxx(int argc) {24  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}25#pragma omp target simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}26  for (int i = 0; i < 10; ++i)27    ;28}29 30struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}31extern S1 a;32class S2 {33  mutable int a;34 35public:36  S2() : a(0) {}37  S2(const S2 &s2) : a(s2.a) {}38  static float S2s;39  static const float S2sc;40};41const float S2::S2sc = 0;42const S2 b;43const S2 ba[5];44class S3 {45  int a;46  S3 &operator=(const S3 &s3);47 48public:49  S3() : a(0) {}50  S3(const S3 &s3) : a(s3.a) {}51};52const S3 c;53const S3 ca[5];54extern const int f;55class S4 {56  int a;57  S4();58  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}59 60public:61  S4(int v) : a(v) {}62};63class S5 {64  int a;65  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}66 67public:68  S5() : a(0) {}69  S5(int v) : a(v) {}70};71class S6 {72  int a;73  S6() : a(0) {}74 75public:76  S6(const S6 &s6) : a(s6.a) {}77  S6(int v) : a(v) {}78};79 80S3 h;81#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}82 83template <class I, class C>84int foomain(int argc, char **argv) {85  I e(4);86  C g(5);87  int i, z;88  int &j = i;89#pragma omp target simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}90  for (int k = 0; k < argc; ++k)91    ++k;92#pragma omp target simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}93  for (int k = 0; k < argc; ++k)94    ++k;95#pragma omp target simd firstprivate() // expected-error {{expected expression}}96  for (int k = 0; k < argc; ++k)97    ++k;98#pragma omp target simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}99  for (int k = 0; k < argc; ++k)100    ++k;101#pragma omp target simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}102  for (int k = 0; k < argc; ++k)103    ++k;104#pragma omp target simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}105  for (int k = 0; k < argc; ++k)106    ++k;107#pragma omp target simd 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 '('}}108  for (int k = 0; k < argc; ++k)109    ++k;110#pragma omp target simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}111  for (int k = 0; k < argc; ++k)112    ++k;113#pragma omp target simd firstprivate(a, b, z) // expected-error {{firstprivate variable with incomplete type 'S1'}}114  for (int k = 0; k < argc; ++k)115    ++k;116#pragma omp target simd firstprivate(argv[1]) // expected-error {{expected variable name}}117  for (int k = 0; k < argc; ++k)118    ++k;119#pragma omp target simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}120  for (int k = 0; k < argc; ++k)121    ++k;122#pragma omp target simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}123  for (int k = 0; k < argc; ++k)124    ++k;125#pragma omp parallel126  {127    int v = 0;128    int i;129#pragma omp target simd allocate(omp_thread_mem_alloc: i) firstprivate(i) uses_allocators(omp_thread_mem_alloc) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target simd' directive}}130    for (int k = 0; k < argc; ++k) {131      i = k;132      v += i;133    }134  }135#pragma omp parallel shared(i)136#pragma omp parallel private(i)137#pragma omp target simd firstprivate(j)138  for (int k = 0; k < argc; ++k)139    ++k;140#pragma omp target simd firstprivate(i)141  for (int k = 0; k < argc; ++k)142    ++k;143#pragma omp target simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}144  for (i = 0; i < argc; ++i)145    foo();146#pragma omp parallel private(i)147#pragma omp target simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}148  for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}149    foo();150#pragma omp parallel reduction(+ : i)151#pragma omp target simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}152  for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}153    foo();154  return 0;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  const int d = 5;167  const int da[5] = {0};168  S4 e(4);169  S5 g(5);170  S3 m;171  S6 n(2);172  int i, z;173  int &j = i;174#pragma omp target simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}175  for (i = 0; i < argc; ++i)176    foo();177#pragma omp target simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}178  for (i = 0; i < argc; ++i)179    foo();180#pragma omp target simd firstprivate() // expected-error {{expected expression}}181  for (i = 0; i < argc; ++i)182    foo();183#pragma omp target simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}184  for (i = 0; i < argc; ++i)185    foo();186#pragma omp target simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}187  for (i = 0; i < argc; ++i)188    foo();189#pragma omp target simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}190  for (i = 0; i < argc; ++i)191    foo();192#pragma omp target simd firstprivate(argc, z)193  for (i = 0; i < argc; ++i)194    foo();195#pragma omp target simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}196  for (i = 0; i < argc; ++i)197    foo();198#pragma omp target simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}199  for (i = 0; i < argc; ++i)200    foo();201#pragma omp target simd firstprivate(argv[1]) // expected-error {{expected variable name}}202  for (i = 0; i < argc; ++i)203    foo();204#pragma omp target simd firstprivate(2 * 2) // expected-error {{expected variable name}}205  for (i = 0; i < argc; ++i)206    foo();207#pragma omp target simd firstprivate(ba) // OK208  for (i = 0; i < argc; ++i)209    foo();210#pragma omp target simd firstprivate(ca) // OK211  for (i = 0; i < argc; ++i)212    foo();213#pragma omp target simd firstprivate(da) // OK214  for (i = 0; i < argc; ++i)215    foo();216  int xa;217#pragma omp target simd firstprivate(xa) // OK218  for (i = 0; i < argc; ++i)219    foo();220#pragma omp target simd firstprivate(S2::S2s) // OK221  for (i = 0; i < argc; ++i)222    foo();223#pragma omp target simd firstprivate(S2::S2sc) // OK224  for (i = 0; i < argc; ++i)225    foo();226#pragma omp target simd safelen(5) // OK227  for (i = 0; i < argc; ++i)228    foo();229#pragma omp target simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}230  for (i = 0; i < argc; ++i)231    foo();232#pragma omp target simd firstprivate(m) // OK233  for (i = 0; i < argc; ++i)234    foo();235#pragma omp target simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}236  for (i = 0; i < argc; ++i)237    foo();238#pragma omp target simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}239  for (i = 0; i < argc; ++i)240    foo();241#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}}242  for (i = 0; i < argc; ++i)    // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}243    foo();244#pragma omp parallel shared(xa)245#pragma omp target simd firstprivate(xa) // OK: may be firstprivate246  for (i = 0; i < argc; ++i)247    foo();248#pragma omp target simd firstprivate(j)249  for (i = 0; i < argc; ++i)250    foo();251#pragma omp target simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}252  for (i = 0; i < argc; ++i)253    foo();254#pragma omp target simd lastprivate(n) firstprivate(n) // OK255  for (i = 0; i < argc; ++i)256    foo();257#pragma omp parallel258  {259    int v = 0;260    int i;261#pragma omp target simd firstprivate(i)262    for (int k = 0; k < argc; ++k) {263      i = k;264      v += i;265    }266  }267#pragma omp parallel private(i)268#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}}269  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}270    foo();271#pragma omp parallel reduction(+ : i)272#pragma omp target simd firstprivate(i) // expected-note {{defined as firstprivate}}273  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target simd' directive may not be firstprivate, predetermined as linear}}274    foo();275  static int si;276#pragma omp target simd firstprivate(si) // OK277  for (i = 0; i < argc; ++i)278    si = i + 1;279 280  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}281}282