xref: /minix3/external/bsd/llvm/dist/clang/test/OpenMP/task_firstprivate_messages.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
2 
foo()3 void foo() {
4 }
5 
foobool(int argc)6 bool foobool(int argc) {
7   return argc;
8 }
9 
10 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14 
15 public:
S2()16   S2() : a(0) {}
S2(const S2 & s2)17   S2(const S2 &s2) : a(s2.a) {}
18   static float S2s;
19   static const float S2sc;
20 };
21 const float S2::S2sc = 0;
22 const S2 b;
23 const S2 ba[5];
24 class S3 {
25   int a;
26 
27 public:
S3()28   S3() : a(0) {}
S3(const S3 & s3)29   S3(const S3 &s3) : a(s3.a) {}
30 };
31 const S3 c;
32 const S3 ca[5];
33 extern const int f;
34 class S4 {
35   int a;
36   S4();
37   S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
38 
39 public:
S4(int v)40   S4(int v) : a(v) {}
41 };
42 class S5 {
43   int a;
S5()44   S5() : a(0) {}
S5(const S5 & s5)45   S5(const S5 &s5) : a(s5.a) {} // expected-note 2 {{implicitly declared private here}}
46 
47 public:
S5(int v)48   S5(int v) : a(v) {}
49 };
50 
51 S3 h;
52 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
53 
main(int argc,char ** argv)54 int main(int argc, char **argv) {
55   const int d = 5;
56   const int da[5] = {0};
57   S4 e(4);
58   S5 g(5);
59   int i;
60   int &j = i;                                               // expected-note {{'j' defined here}}
61 #pragma omp task firstprivate                               // expected-error {{expected '(' after 'firstprivate'}}
62 #pragma omp task firstprivate(                              // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
63 #pragma omp task firstprivate()                             // expected-error {{expected expression}}
64 #pragma omp task firstprivate(argc                          // expected-error {{expected ')'}} expected-note {{to match this '('}}
65 #pragma omp task firstprivate(argc,                         // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
66 #pragma omp task firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
67 #pragma omp task firstprivate(argc)
68 #pragma omp task firstprivate(S1)            // expected-error {{'S1' does not refer to a value}}
69 #pragma omp task firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
70 #pragma omp task firstprivate(argv[1])       // expected-error {{expected variable name}}
71 #pragma omp task firstprivate(ba)
72 #pragma omp task firstprivate(ca)
73 #pragma omp task firstprivate(da)
74 #pragma omp task firstprivate(S2::S2s)
75 #pragma omp task firstprivate(S2::S2sc)
76 #pragma omp task firstprivate(e, g)          // expected-error 2 {{calling a private constructor of class 'S4'}} expected-error 2 {{calling a private constructor of class 'S5'}}
77 #pragma omp task firstprivate(h)             // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
78 #pragma omp task private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
79   foo();
80 #pragma omp task shared(i)
81 #pragma omp task firstprivate(i)
82 #pragma omp task firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
83   foo();
84 
85   return 0;
86 }
87