brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.0 KiB · bc1dfcf Raw
366 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized4 5extern int omp_default_mem_alloc;6void foo() {7}8 9bool foobool(int argc) {10  return argc;11}12 13struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}14extern S1 a;15class S2 {16  mutable int a;17 18public:19  S2() : a(0) {}20  S2(const S2 &s2) : a(s2.a) {}21  static float S2s;22  static const float S2sc;23};24const float S2::S2sc = 0;25const S2 b;26const S2 ba[5];27class S3 {28  int a;29  S3 &operator=(const S3 &s3);30 31public:32  S3() : a(0) {}33  S3(const S3 &s3) : a(s3.a) {}34};35const S3 c;36const S3 ca[5];37extern const int f;38class S4 {39  int a;40  S4();41  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}42 43public:44  S4(int v) : a(v) {}45};46class S5 {47  int a;48  S5(const S5 &s5) : a(s5.a) {} // expected-note 2 {{implicitly declared private here}}49 50public:51  S5() : a(0) {}52  S5(int v) : a(v) {}53};54class S6 {55  int a;56  S6() : a(0) {} // expected-note {{implicitly declared private here}}57 58public:59  S6(const S6 &s6) : a(s6.a) {}60  S6(int v) : a(v) {}61};62 63S3 h;64#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}65 66template <class I, class C>67int foomain(int argc, char **argv) {68  I e(4);69  C g(5);70  int i, z;71  int &j = i;72#pragma omp target73#pragma omp teams74#pragma omp distribute simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}75  for (int k = 0; k < argc; ++k)76    ++k;77#pragma omp target78#pragma omp teams79#pragma omp distribute simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}80  for (int k = 0; k < argc; ++k)81    ++k;82#pragma omp target83#pragma omp teams84#pragma omp distribute simd firstprivate() // expected-error {{expected expression}}85  for (int k = 0; k < argc; ++k)86    ++k;87#pragma omp target88#pragma omp teams89#pragma omp distribute simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}90  for (int k = 0; k < argc; ++k)91    ++k;92#pragma omp target93#pragma omp teams94#pragma omp distribute simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}95  for (int k = 0; k < argc; ++k)96    ++k;97#pragma omp target98#pragma omp teams99#pragma omp distribute simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}100  for (int k = 0; k < argc; ++k)101    ++k;102#pragma omp target103#pragma omp teams104#pragma omp distribute 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 '('}}105  for (int k = 0; k < argc; ++k)106    ++k;107#pragma omp target108#pragma omp teams109#pragma omp distribute simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}110  for (int k = 0; k < argc; ++k)111    ++k;112#pragma omp target113#pragma omp teams114#pragma omp distribute simd firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-warning {{type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}}115  for (int k = 0; k < argc; ++k)116    ++k;117#pragma omp target118#pragma omp teams119#pragma omp distribute simd firstprivate(argv[1]) // expected-error {{expected variable name}}120  for (int k = 0; k < argc; ++k)121    ++k;122#pragma omp target123#pragma omp teams124#pragma omp distribute simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} expected-warning {{type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}125  for (int k = 0; k < argc; ++k)126    ++k;127#pragma omp target128#pragma omp teams129#pragma omp distribute simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}130  for (int k = 0; k < argc; ++k)131    ++k;132#pragma omp parallel133  {134    int v = 0;135    int i;136#pragma omp target137#pragma omp teams138#pragma omp distribute simd firstprivate(i)139    for (int k = 0; k < argc; ++k) {140      i = k;141      v += i;142    }143  }144#pragma omp parallel shared(i)145#pragma omp parallel private(i)146#pragma omp target147#pragma omp teams148#pragma omp distribute simd firstprivate(j)149  for (int k = 0; k < argc; ++k)150    ++k;151#pragma omp target152#pragma omp teams153#pragma omp distribute simd firstprivate(i)154  for (int k = 0; k < argc; ++k)155    ++k;156// expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}157#pragma omp target158#pragma omp teams159#pragma omp distribute simd lastprivate(g) firstprivate(g)160  for (i = 0; i < argc; ++i)161    foo();162#pragma omp parallel private(i)163#pragma omp target164#pragma omp teams165#pragma omp distribute simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}166  for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}167    foo();168#pragma omp parallel reduction(+ : i)169#pragma omp target170#pragma omp teams171#pragma omp distribute simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}172  for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}173    foo();174  return 0;175}176 177namespace A {178double x;179#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}180}181namespace B {182using A::x;183}184 185int main(int argc, char **argv) {186  const int d = 5;187  const int da[5] = {0};188  S4 e(4);189  S5 g(5);190  S3 m;191  S6 n(2);192  int i, z;193  int &j = i;194#pragma omp target195#pragma omp teams196#pragma omp distribute simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}197  for (i = 0; i < argc; ++i)198    foo();199#pragma omp target200#pragma omp teams201#pragma omp distribute simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}202  for (i = 0; i < argc; ++i)203    foo();204#pragma omp target205#pragma omp teams206#pragma omp distribute simd firstprivate() // expected-error {{expected expression}}207  for (i = 0; i < argc; ++i)208    foo();209#pragma omp target210#pragma omp teams211#pragma omp distribute simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}212  for (i = 0; i < argc; ++i)213    foo();214#pragma omp target215#pragma omp teams216#pragma omp distribute simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}217  for (i = 0; i < argc; ++i)218    foo();219#pragma omp target220#pragma omp teams221#pragma omp distribute simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}222  for (i = 0; i < argc; ++i)223    foo();224#pragma omp target225#pragma omp teams226#pragma omp distribute simd firstprivate(argc, z)227  for (i = 0; i < argc; ++i)228    foo();229#pragma omp target230#pragma omp teams231#pragma omp distribute simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}232  for (i = 0; i < argc; ++i)233    foo();234#pragma omp target235#pragma omp teams236#pragma omp distribute simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{incomplete type 'S1' where a complete type is required}} expected-warning {{type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'const S3' is not trivially copyable and not guaranteed to be mapped correctly}}237  for (i = 0; i < argc; ++i)238    foo();239#pragma omp target240#pragma omp teams241#pragma omp distribute simd firstprivate(argv[1]) // expected-error {{expected variable name}}242  for (i = 0; i < argc; ++i)243    foo();244#pragma omp target245#pragma omp teams246#pragma omp distribute simd firstprivate(2 * 2) // expected-error {{expected variable name}}247  for (i = 0; i < argc; ++i)248    foo();249#pragma omp target250#pragma omp teams251#pragma omp distribute simd firstprivate(ba) // expected-warning {{type 'const S2[5]' is not trivially copyable and not guaranteed to be mapped correctly}}252  for (i = 0; i < argc; ++i)253    foo();254#pragma omp target255#pragma omp teams256#pragma omp distribute simd firstprivate(ca) // expected-warning {{type 'const S3[5]' is not trivially copyable and not guaranteed to be mapped correctly}}257  for (i = 0; i < argc; ++i)258    foo();259#pragma omp target260#pragma omp teams261#pragma omp distribute simd firstprivate(da) // OK262  for (i = 0; i < argc; ++i)263    foo();264  int xa;265#pragma omp target266#pragma omp teams267#pragma omp distribute simd firstprivate(xa) // OK268  for (i = 0; i < argc; ++i)269    foo();270#pragma omp target271#pragma omp teams272#pragma omp distribute simd firstprivate(S2::S2s) // OK273  for (i = 0; i < argc; ++i)274    foo();275#pragma omp target276#pragma omp teams277#pragma omp distribute simd firstprivate(S2::S2sc) // OK278  for (i = 0; i < argc; ++i)279    foo();280#pragma omp target281#pragma omp teams282#pragma omp distribute simd safelen(5) // OK283  for (i = 0; i < argc; ++i)284    foo();285#pragma omp target286#pragma omp teams287#pragma omp distribute simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} expected-warning {{type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}288  for (i = 0; i < argc; ++i)289    foo();290#pragma omp target291#pragma omp teams292#pragma omp distribute simd firstprivate(m) // expected-warning {{type 'S3' is not trivially copyable and not guaranteed to be mapped correctly}}293  for (i = 0; i < argc; ++i)294    foo();295#pragma omp target296#pragma omp teams297#pragma omp distribute simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}298  for (i = 0; i < argc; ++i)299    foo();300#pragma omp target301#pragma omp teams302#pragma omp distribute simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}303  for (i = 0; i < argc; ++i)304    foo();305#pragma omp target306#pragma omp teams307#pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}308  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}309    foo();310#pragma omp parallel shared(xa)311#pragma omp target312#pragma omp teams313#pragma omp distribute simd firstprivate(xa) // OK: may be firstprivate314  for (i = 0; i < argc; ++i)315    foo();316#pragma omp target317#pragma omp teams318#pragma omp distribute simd firstprivate(j)319  for (i = 0; i < argc; ++i)320    foo();321// expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}322#pragma omp target323#pragma omp teams324#pragma omp distribute simd lastprivate(g) firstprivate(g) //expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}325  for (i = 0; i < argc; ++i)326    foo();327// expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}328#pragma omp target329#pragma omp teams330#pragma omp distribute simd lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}} expected-warning {{type 'S6' is not trivially copyable and not guaranteed to be mapped correctly}}331  for (i = 0; i < argc; ++i)332    foo();333#pragma omp parallel334  {335    int v = 0;336    int i;337#pragma omp target338#pragma omp teams339#pragma omp distribute simd firstprivate(i)340    for (int k = 0; k < argc; ++k) {341      i = k;342      v += i;343    }344  }345#pragma omp parallel private(i)346#pragma omp target347#pragma omp teams348#pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}349  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}350    foo();351#pragma omp parallel reduction(+ : i)352#pragma omp target353#pragma omp teams354#pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}355  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}356    foo();357  static int si;358#pragma omp target359#pragma omp teams360#pragma omp distribute simd firstprivate(si) // OK361  for (i = 0; i < argc; ++i)362    si = i + 1;363 364  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}365}366