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