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