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