brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.1 KiB · c264a3d Raw
340 lines · cpp
1// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp %s -Wuninitialized2// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp %s -Wuninitialized3 4// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd %s -Wuninitialized5// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd %s -Wuninitialized6 7extern int omp_default_mem_alloc;8void foo() {9}10 11bool foobool(int argc) {12  return argc;13}14 15struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}16extern S1 a;17class S2 {18  mutable int a;19 20public:21  S2() : a(0) {}22  S2(S2 &s2) : a(s2.a) {}23  const S2 &operator=(const S2 &) const;24  static float S2s; // expected-note {{static data member is predetermined as shared}}25  static const float S2sc; // expected-note {{'S2sc' declared here}}26};27const float S2::S2sc = 0;28const S2 b;29const S2 ba[5];30class S3 {31  int a;32  S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}}33 34public:35  S3() : a(0) {}36  S3(S3 &s3) : a(s3.a) {}37};38const S3 c;         // expected-note {{'c' defined here}}39const S3 ca[5];     // expected-note {{'ca' defined here}}40extern const int f; // expected-note {{'f' declared here}}41class S4 {42  int a;43  S4();          // expected-note 3 {{implicitly declared private here}}44  S4(const S4 &s4);45 46public:47  S4(int v) : a(v) {}48};49class S5 {50  int a;51  S5() : a(0) {} // expected-note {{implicitly declared private here}}52 53public:54  S5(const S5 &s5) : a(s5.a) {}55  S5(int v) : a(v) {}56};57class S6 {58  int a;59  S6() : a(0) {} // omp45-note 2 {{implicitly declared private here}}60 61public:62  S6(const S6 &s6) : a(s6.a) {}63  S6(int v) : a(v) {}64};65 66S3 h;67#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}68 69template <class I, class C>70int foomain(int argc, char **argv) {71  I e(4);72  I g(5);73  int i, k;74  int &j = i;75  S6 s(0); // omp51-note {{'s' defined here}}76#pragma omp parallel77#pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}78  {79    foo();80  }81#pragma omp parallel82#pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}83  {84    foo();85  }86#pragma omp parallel87#pragma omp sections lastprivate() // expected-error {{expected expression}}88  {89    foo();90  }91#pragma omp parallel92#pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}93  {94    foo();95  }96#pragma omp parallel97#pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}98  {99    foo();100  }101#pragma omp parallel102#pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}103  {104    foo();105  }106#pragma omp parallel107#pragma omp sections lastprivate(argc)108  {109    foo();110  }111#pragma omp parallel112#pragma omp sections lastprivate(conditional: argc,s) lastprivate(conditional: // omp51-error {{expected expression}} omp45-error 2 {{use of undeclared identifier 'conditional'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp45-error 2 {{calling a private constructor of class 'S6'}} omp51-error {{expected list item of scalar type in 'lastprivate' clause with 'conditional' modifier}}}113  {114    foo();115  }116#pragma omp parallel117#pragma omp sections lastprivate(foo:argc) // omp51-error {{expected 'conditional' in OpenMP clause 'lastprivate'}} omp45-error {{expected ',' or ')' in 'lastprivate' clause}} omp45-error {{expected ')'}} omp45-error {{expected variable name}} omp45-note {{to match this '('}}118  {119    foo();120  }121#pragma omp parallel122#pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}123  {124    foo();125  }126#pragma omp parallel127#pragma omp sections lastprivate(a, b, k) // expected-error {{lastprivate variable with incomplete type 'S1'}}128  {129    foo();130  }131#pragma omp parallel132#pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}}133  {134    foo();135  }136#pragma omp parallel137#pragma omp sections lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}138  {139    foo();140  }141#pragma omp parallel142#pragma omp sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}143  {144    foo();145  }146#pragma omp parallel147#pragma omp sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}}148  {149    foo();150  }151#pragma omp parallel152  {153    int v = 0;154    int i;                          // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}}155#pragma omp sections lastprivate(i) // expected-error {{lastprivate variable must be shared}}156    {157      foo();158    }159    v += i;160  }161#pragma omp parallel shared(i)162#pragma omp parallel private(i)163#pragma omp sections lastprivate(j)164  {165    foo();166  }167#pragma omp parallel168#pragma omp sections lastprivate(i)169  {170    foo();171  }172  return 0;173}174 175namespace A {176double x;177#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}178}179namespace B {180using A::x;181}182 183int main(int argc, char **argv) {184  const int d = 5;       // expected-note {{'d' defined here}}185  const int da[5] = {0}; // expected-note {{'da' defined here}}186  S4 e(4);187  S5 g(5);188  S3 m;189  S6 n(2);190  int i, k;191  int &j = i;192#pragma omp parallel193#pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}194  {195    foo();196  }197#pragma omp parallel198#pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}199  {200    foo();201  }202#pragma omp parallel203#pragma omp sections lastprivate() // expected-error {{expected expression}}204  {205    foo();206  }207#pragma omp parallel208#pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}209  {210    foo();211  }212#pragma omp parallel213#pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}214  {215    foo();216  }217#pragma omp parallel218#pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}219  {220    foo();221  }222#pragma omp parallel223#pragma omp sections lastprivate(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 '('}}224  {225    foo();226  }227#pragma omp parallel228#pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}229  {230    foo();231  }232#pragma omp parallel233#pragma omp sections lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be lastprivate}} expected-error 2 {{const-qualified variable cannot be lastprivate}}234  {235    foo();236  }237#pragma omp parallel238#pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}}239  {240    foo();241  }242#pragma omp parallel243#pragma omp sections lastprivate(2 * 2) // expected-error {{expected variable name}}244  {245    foo();246  }247#pragma omp parallel248#pragma omp sections lastprivate(ba, k)249  {250    foo();251  }252#pragma omp parallel253#pragma omp sections lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}}254  {255    foo();256  }257#pragma omp parallel258#pragma omp sections lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}}259  {260    foo();261  }262  int xa;263#pragma omp parallel264#pragma omp sections lastprivate(xa) // OK265  {266    foo();267  }268#pragma omp parallel269#pragma omp sections lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}270  {271    foo();272  }273#pragma omp parallel274#pragma omp sections lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}}275  {276    foo();277  }278#pragma omp parallel279#pragma omp sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp sections'}}280  {281    foo();282  }283#pragma omp parallel284#pragma omp sections lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}285  {286    foo();287  }288#pragma omp parallel289#pragma omp sections lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}290  {291    foo();292  }293#pragma omp parallel294#pragma omp sections lastprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be lastprivate}}295  {296    foo();297  }298#pragma omp parallel299#pragma omp sections private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}300  {301    foo();302  }303#pragma omp parallel304#pragma omp sections lastprivate(i)305  {306    foo();307  }308#pragma omp parallel private(xa)     // expected-note {{defined as private}}309#pragma omp sections lastprivate(xa) // expected-error {{lastprivate variable must be shared}}310  {311    foo();312  }313#pragma omp parallel reduction(+ : xa) // expected-note {{defined as reduction}}314#pragma omp sections lastprivate(xa)   // expected-error {{lastprivate variable must be shared}}315  {316    foo();317  }318#pragma omp parallel319#pragma omp sections lastprivate(j)320  {321    foo();322  }323#pragma omp parallel324#pragma omp sections firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}325  {326    foo();327  }328#pragma omp parallel329#pragma omp sections lastprivate(n) firstprivate(n) // OK330  {331    foo();332  }333  static int r;334#pragma omp sections lastprivate(r) // OK335  {336    foo();337  }338  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}339}340