brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.8 KiB · 4bed1fe Raw
374 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized4 5void foo() {6}7 8bool foobool(int argc) {9  return argc;10}11 12void xxx(int argc) {13  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}14#pragma omp distribute parallel for firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}15  for (int i = 0; i < 10; ++i)16    ;17}18 19extern int omp_default_mem_alloc;20 21struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}22extern S1 a;23class S2 {24  mutable int a;25 26public:27  S2() : a(0) {}28  S2(const S2 &s2) : a(s2.a) {}29  static float S2s;30  static const float S2sc;31};32const float S2::S2sc = 0;33const S2 b;34const S2 ba[5];35class S3 {36  int a;37  S3 &operator=(const S3 &s3);38 39public:40  S3() : a(0) {}41  S3(const S3 &s3) : a(s3.a) {}42};43const S3 c;44const S3 ca[5];45extern const int f;46class S4 {47  int a;48  S4();49  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}50 51public:52  S4(int v) : a(v) {}53};54class S5 {55  int a;56  S5(const S5 &s5) : a(s5.a) {} // expected-note 2 {{implicitly declared private here}}57 58public:59  S5() : a(0) {}60  S5(int v) : a(v) {}61};62class S6 {63  int a;64  S6() : a(0) {} // expected-note {{implicitly declared private here}}65 66public:67  S6(const S6 &s6) : a(s6.a) {}68  S6(int v) : a(v) {}69};70 71S3 h;72#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}73 74template <class I, class C>75int foomain(int argc, char **argv) {76  I e(4);77  C g(5);78  int i, k;79  int &j = i;80#pragma omp target81#pragma omp teams82#pragma omp distribute parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}83  for (int k = 0; k < argc; ++k)84    ++k;85#pragma omp target86#pragma omp teams87#pragma omp distribute parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}88  for (int k = 0; k < argc; ++k)89    ++k;90#pragma omp target91#pragma omp teams92#pragma omp distribute parallel for firstprivate() // expected-error {{expected expression}}93  for (int k = 0; k < argc; ++k)94    ++k;95#pragma omp target96#pragma omp teams97#pragma omp distribute parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}98  for (int k = 0; k < argc; ++k)99    ++k;100#pragma omp target101#pragma omp teams102#pragma omp distribute parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}103  for (int k = 0; k < argc; ++k)104    ++k;105#pragma omp target106#pragma omp teams107#pragma omp distribute parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}108  for (int k = 0; k < argc; ++k)109    ++k;110#pragma omp target111#pragma omp teams112#pragma omp distribute parallel for 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 '('}}113  for (int k = 0; k < argc; ++k)114    ++k;115#pragma omp target116#pragma omp teams117#pragma omp distribute parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}118  for (int k = 0; k < argc; ++k)119    ++k;120#pragma omp target121#pragma omp teams122#pragma omp distribute parallel for firstprivate(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}}123  for (int k = 0; k < argc; ++k)124    ++k;125#pragma omp target126#pragma omp teams127#pragma omp distribute parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}128  for (int k = 0; k < argc; ++k)129    ++k;130#pragma omp target131#pragma omp teams132#pragma omp distribute parallel for 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}}133  for (int k = 0; k < argc; ++k)134    ++k;135#pragma omp target136#pragma omp teams137#pragma omp distribute parallel for firstprivate(k, h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}138  for (int k = 0; k < argc; ++k)139    ++k;140#pragma omp parallel141  {142    int v = 0;143    int i;144#pragma omp target145#pragma omp teams146#pragma omp distribute parallel for firstprivate(i)147    for (int k = 0; k < argc; ++k) {148      i = k;149      v += i;150    }151  }152#pragma omp parallel shared(i)153#pragma omp parallel private(i)154#pragma omp target155#pragma omp teams156#pragma omp distribute parallel for firstprivate(j)157  for (int k = 0; k < argc; ++k)158    ++k;159#pragma omp target160#pragma omp teams161#pragma omp distribute parallel for firstprivate(i)162  for (int k = 0; k < argc; ++k)163    ++k;164// expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}165#pragma omp target166#pragma omp teams167#pragma omp distribute parallel for lastprivate(g) firstprivate(g)168  for (i = 0; i < argc; ++i)169    foo();170#pragma omp parallel private(i)171#pragma omp target172#pragma omp teams173#pragma omp distribute parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}174  for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}175    foo();176#pragma omp parallel reduction(+ : i)177#pragma omp target178#pragma omp teams179#pragma omp distribute parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}180  for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}181    foo();182  return 0;183}184 185namespace A {186double x;187#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}188}189namespace B {190using A::x;191}192 193int main(int argc, char **argv) {194  const int d = 5;195  const int da[5] = {0};196  S4 e(4);197  S5 g(5);198  S3 m;199  S6 n(2);200  int i, k;201  int &j = i;202#pragma omp target203#pragma omp teams204#pragma omp distribute parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}205  for (i = 0; i < argc; ++i)206    foo();207#pragma omp target208#pragma omp teams209#pragma omp distribute parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}210  for (i = 0; i < argc; ++i)211    foo();212#pragma omp target213#pragma omp teams214#pragma omp distribute parallel for firstprivate() // expected-error {{expected expression}}215  for (i = 0; i < argc; ++i)216    foo();217#pragma omp target218#pragma omp teams219#pragma omp distribute parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}220  for (i = 0; i < argc; ++i)221    foo();222#pragma omp target223#pragma omp teams224#pragma omp distribute parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}225  for (i = 0; i < argc; ++i)226    foo();227#pragma omp target228#pragma omp teams229#pragma omp distribute parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}230  for (i = 0; i < argc; ++i)231    foo();232#pragma omp target233#pragma omp teams234#pragma omp distribute parallel for firstprivate(argc)235  for (i = 0; i < argc; ++i)236    foo();237#pragma omp target238#pragma omp teams239#pragma omp distribute parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}240  for (i = 0; i < argc; ++i)241    foo();242#pragma omp target243#pragma omp teams244#pragma omp distribute parallel for 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}}245  for (i = 0; i < argc; ++i)246    foo();247#pragma omp target248#pragma omp teams249#pragma omp distribute parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}250  for (i = 0; i < argc; ++i)251    foo();252#pragma omp target253#pragma omp teams254#pragma omp distribute parallel for firstprivate(2 * 2) // expected-error {{expected variable name}}255  for (i = 0; i < argc; ++i)256    foo();257#pragma omp target258#pragma omp teams259#pragma omp distribute parallel for firstprivate(ba) // expected-warning {{type 'const S2[5]' is not trivially copyable and not guaranteed to be mapped correctly}}260  for (i = 0; i < argc; ++i)261    foo();262#pragma omp target263#pragma omp teams264#pragma omp distribute parallel for firstprivate(ca) // expected-warning {{type 'const S3[5]' is not trivially copyable and not guaranteed to be mapped correctly}}265  for (i = 0; i < argc; ++i)266    foo();267#pragma omp target268#pragma omp teams269#pragma omp distribute parallel for firstprivate(da) // OK270  for (i = 0; i < argc; ++i)271    foo();272  int xa;273#pragma omp target274#pragma omp teams275#pragma omp distribute parallel for firstprivate(xa) // OK276  for (i = 0; i < argc; ++i)277    foo();278#pragma omp target279#pragma omp teams280#pragma omp distribute parallel for firstprivate(S2::S2s) // OK281  for (i = 0; i < argc; ++i)282    foo();283#pragma omp target284#pragma omp teams285#pragma omp distribute parallel for firstprivate(S2::S2sc) // OK286  for (i = 0; i < argc; ++i)287    foo();288#pragma omp target289#pragma omp teams290#pragma omp distribute parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp distribute parallel for'}}291  for (i = 0; i < argc; ++i)292    foo();293#pragma omp target294#pragma omp teams295#pragma omp distribute parallel for 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}}296  for (i = 0; i < argc; ++i)297    foo();298#pragma omp target299#pragma omp teams300#pragma omp distribute parallel for firstprivate(m) // expected-warning {{type 'S3' is not trivially copyable and not guaranteed to be mapped correctly}}301  for (i = 0; i < argc; ++i)302    foo();303#pragma omp target304#pragma omp teams305#pragma omp distribute parallel for firstprivate(k, h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}306  for (i = 0; i < argc; ++i)307    foo();308#pragma omp target309#pragma omp teams310#pragma omp distribute parallel for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}311  for (i = 0; i < argc; ++i)312    foo();313#pragma omp target314#pragma omp teams315#pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}316  for (i = 0; i < argc; ++i)    // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}317    foo();318#pragma omp parallel shared(xa)319#pragma omp target320#pragma omp teams321#pragma omp distribute parallel for firstprivate(xa) // OK: may be firstprivate322  for (i = 0; i < argc; ++i)323    foo();324#pragma omp target325#pragma omp teams326#pragma omp distribute parallel for firstprivate(j)327  for (i = 0; i < argc; ++i)328    foo();329// expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}330#pragma omp target331#pragma omp teams332#pragma omp distribute parallel for lastprivate(g) firstprivate(g) // expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}333  for (i = 0; i < argc; ++i)334    foo();335// expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}336#pragma omp target337#pragma omp teams338#pragma omp distribute parallel for 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}}339  for (i = 0; i < argc; ++i)340    foo();341#pragma omp parallel342  {343    int v = 0;344    int i;345#pragma omp target346#pragma omp teams347#pragma omp distribute parallel for firstprivate(i)348    for (int k = 0; k < argc; ++k) {349      i = k;350      v += i;351    }352  }353#pragma omp parallel private(i)354#pragma omp target355#pragma omp teams356#pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}357  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}358    foo();359#pragma omp parallel reduction(+ : i)360#pragma omp target361#pragma omp teams362#pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}363  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}364    foo();365  static int si;366#pragma omp target367#pragma omp teams368#pragma omp distribute parallel for firstprivate(si) // OK369  for (i = 0; i < argc; ++i)370    si = i + 1;371 372  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}373}374