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