• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp %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 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14 
15 public:
S2()16   S2() : a(0) {}
S2(S2 & s2)17   S2(S2 &s2) : a(s2.a) {}
18   S2 &operator=(const S2 &);
19   const S2 &operator=(const S2 &) const;
20   static float S2s; // expected-note {{static data member is predetermined as shared}}
21   static const float S2sc;
22 };
23 const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
24 const S2 b;
25 const S2 ba[5];
26 class S3 {
27   int a;
28   S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}}
29 
30 public:
S3()31   S3() : a(0) {}
S3(S3 & s3)32   S3(S3 &s3) : a(s3.a) {}
33 };
34 const S3 c;         // expected-note {{global variable is predetermined as shared}}
35 const S3 ca[5];     // expected-note {{global variable is predetermined as shared}}
36 extern const int f; // expected-note {{global variable is predetermined as shared}}
37 class S4 {
38   int a;
39   S4();             // expected-note 3 {{implicitly declared private here}}
40   S4(const S4 &s4);
41 
42 public:
S4(int v)43   S4(int v) : a(v) {}
44 };
45 class S5 {
46   int a;
S5()47   S5() : a(0) {} // expected-note {{implicitly declared private here}}
48 
49 public:
S5(const S5 & s5)50   S5(const S5 &s5) : a(s5.a) {}
S5(int v)51   S5(int v) : a(v) {}
52 };
53 class S6 {
54   int a;
S6()55   S6() : a(0) {}
56 
57 public:
S6(const S6 & s6)58   S6(const S6 &s6) : a(s6.a) {}
S6(int v)59   S6(int v) : a(v) {}
60 };
61 
62 S3 h;
63 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
64 
65 template <class I, class C>
foomain(int argc,char ** argv)66 int foomain(int argc, char **argv) {
67   I e(4);
68   I g(5);
69   int i;
70   int &j = i;
71 #pragma omp target parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
72   for (int k = 0; k < argc; ++k)
73     ++k;
74 #pragma omp target parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75   for (int k = 0; k < argc; ++k)
76     ++k;
77 #pragma omp target parallel for lastprivate() // expected-error {{expected expression}}
78   for (int k = 0; k < argc; ++k)
79     ++k;
80 #pragma omp target parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
81   for (int k = 0; k < argc; ++k)
82     ++k;
83 #pragma omp target parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
84   for (int k = 0; k < argc; ++k)
85     ++k;
86 #pragma omp target parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
87   for (int k = 0; k < argc; ++k)
88     ++k;
89 #pragma omp target parallel for lastprivate(argc)
90   for (int k = 0; k < argc; ++k)
91     ++k;
92 #pragma omp target parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
93   for (int k = 0; k < argc; ++k)
94     ++k;
95 #pragma omp target parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
96   for (int k = 0; k < argc; ++k)
97     ++k;
98 #pragma omp target parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
99   for (int k = 0; k < argc; ++k)
100     ++k;
101 #pragma omp target parallel for lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
102   for (int k = 0; k < argc; ++k)
103     ++k;
104 #pragma omp target parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
105   for (int k = 0; k < argc; ++k)
106     ++k;
107 #pragma omp parallel
108   {
109     int v = 0;
110     int i;
111 #pragma omp target parallel for lastprivate(i)
112     for (int k = 0; k < argc; ++k) {
113       i = k;
114       v += i;
115     }
116   }
117 #pragma omp parallel shared(i)
118 #pragma omp parallel private(i)
119 #pragma omp target parallel for lastprivate(j)
120   for (int k = 0; k < argc; ++k)
121     ++k;
122 #pragma omp target parallel for lastprivate(i)
123   for (int k = 0; k < argc; ++k)
124     ++k;
125   return 0;
126 }
127 
128 namespace A {
129 double x;
130 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
131 }
132 namespace B {
133 using A::x;
134 }
135 
main(int argc,char ** argv)136 int main(int argc, char **argv) {
137   const int d = 5;       // expected-note {{constant variable is predetermined as shared}}
138   const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
139   S4 e(4);
140   S5 g(5);
141   S3 m;
142   S6 n(2);
143   int i;
144   int &j = i;
145 #pragma omp target parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
146   for (i = 0; i < argc; ++i)
147     foo();
148 #pragma omp target parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
149   for (i = 0; i < argc; ++i)
150     foo();
151 #pragma omp target parallel for lastprivate() // expected-error {{expected expression}}
152   for (i = 0; i < argc; ++i)
153     foo();
154 #pragma omp target parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
155   for (i = 0; i < argc; ++i)
156     foo();
157 #pragma omp target parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
158   for (i = 0; i < argc; ++i)
159     foo();
160 #pragma omp target parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
161   for (i = 0; i < argc; ++i)
162     foo();
163 #pragma omp target parallel for lastprivate(argc)
164   for (i = 0; i < argc; ++i)
165     foo();
166 #pragma omp target parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
167   for (i = 0; i < argc; ++i)
168     foo();
169 #pragma omp target parallel for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
170   for (i = 0; i < argc; ++i)
171     foo();
172 #pragma omp target parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
173   for (i = 0; i < argc; ++i)
174     foo();
175 #pragma omp target parallel for lastprivate(2 * 2) // expected-error {{expected variable name}}
176   for (i = 0; i < argc; ++i)
177     foo();
178 #pragma omp target parallel for lastprivate(ba)
179   for (i = 0; i < argc; ++i)
180     foo();
181 #pragma omp target parallel for lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
182   for (i = 0; i < argc; ++i)
183     foo();
184 #pragma omp target parallel for lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
185   for (i = 0; i < argc; ++i)
186     foo();
187   int xa;
188 #pragma omp target parallel for lastprivate(xa) // OK
189   for (i = 0; i < argc; ++i)
190     foo();
191 #pragma omp target parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
192   for (i = 0; i < argc; ++i)
193     foo();
194 #pragma omp target parallel for lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
195   for (i = 0; i < argc; ++i)
196     foo();
197 #pragma omp target parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp target parallel for'}}
198   for (i = 0; i < argc; ++i)
199     foo();
200 #pragma omp target parallel for lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
201   for (i = 0; i < argc; ++i)
202     foo();
203 #pragma omp target parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
204   for (i = 0; i < argc; ++i)
205     foo();
206 #pragma omp target parallel for lastprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be lastprivate}}
207   for (i = 0; i < argc; ++i)
208     foo();
209 #pragma omp target parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
210   for (i = 0; i < argc; ++i)
211     foo();
212 #pragma omp target parallel for lastprivate(i)
213   for (i = 0; i < argc; ++i)
214     foo();
215 #pragma omp parallel private(xa)
216 #pragma omp target parallel for lastprivate(xa)
217   for (i = 0; i < argc; ++i)
218     foo();
219 #pragma omp parallel reduction(+ : xa)
220 #pragma omp target parallel for lastprivate(xa)
221   for (i = 0; i < argc; ++i)
222     foo();
223 #pragma omp target parallel for lastprivate(j)
224   for (i = 0; i < argc; ++i)
225     foo();
226 #pragma omp target parallel for firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
227   for (i = 0; i < argc; ++i)
228     foo();
229 #pragma omp target parallel for lastprivate(n) firstprivate(n) // OK
230   for (i = 0; i < argc; ++i)
231     foo();
232   static int si;
233 #pragma omp target parallel for lastprivate(si) // OK
234   for (i = 0; i < argc; ++i)
235     si = i + 2;
236 
237   return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
238 }
239