Delete unused PoisonChecking utility pass
[llvm-project.git] / clang / test / CXX / temp / temp.spec / part.spec.cpp
blob4b0fdb902633a197d94beb131e1e16fa744aebd5
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // C++20 [temp.class.spec] 13.7.5/10
4 // The usual access checking rules do not apply to non-dependent names
5 // used to specify template arguments of the simple-template-id of the
6 // partial specialization.
7 //
8 // C++20 [temp.spec] 13.9/6:
9 // The usual access checking rules do not apply to names in a declaration
10 // of an explicit instantiation or explicit specialization...
12 // TODO: add test cases for `enum`
14 // class for tests
15 class TestClass {
16 public:
17 class PublicClass {};
18 template <class T> class TemplatePublicClass {};
20 using AliasPublicClass = unsigned char;
22 void publicFunc();
23 void publicFuncOverloaded();
24 void publicFuncOverloaded(int);
26 static void publicStaticFunc();
27 static void publicStaticFuncOverloaded();
28 static void publicStaticFuncOverloaded(int);
30 static constexpr int publicStaticInt = 42;
32 protected:
33 // expected-note@+1 8{{declared protected here}}
34 class ProtectedClass {};
35 template <class T> class TemplateProtectedClass {};
37 // expected-note@+1 2{{declared protected here}}
38 using AliasProtectedClass = const char;
40 // expected-note@+1 3{{declared protected here}}
41 void protectedFunc();
42 void protectedFuncOverloaded();
43 void protectedFuncOverloaded(int);
45 // expected-note@+1 2{{declared protected here}}
46 static void protectedStaticFunc();
47 // expected-note@+1 2{{declared protected here}}
48 static void protectedStaticFuncOverloaded();
49 static void protectedStaticFuncOverloaded(int);
51 // expected-note@+1 2{{declared protected here}}
52 static constexpr int protectedStaticInt = 43;
54 private:
55 // expected-note@+1 10{{declared private here}}
56 class PrivateClass {};
57 // expected-note@+1 {{declared private here}}
58 template <class T> class TemplatePrivateClass {};
60 using AliasPrivateClass = char *;
62 void privateFunc();
63 void privateFuncOverloaded();
64 void privateFuncOverloaded(int);
66 static void privateStaticFunc();
67 static void privateStaticFuncOverloaded();
68 static void privateStaticFuncOverloaded(int);
70 static constexpr int privateStaticInt = 44;
73 void globalFunction() {}
75 //----------------------------------------------------------//
77 // template declarations for explicit instantiations
78 template <typename T> class IT1 {};
79 template <typename T1, typename T2> class IT2 {};
80 template <int X> class IT3 {};
81 template <void (TestClass::*)()> class IT4 {};
82 template <void (*)()> class IT5 {};
83 template <typename T> class IT6 {
84 template <typename NT> class NIT1 {};
86 template <typename T1, typename T2> class IT7 {};
87 template <void (TestClass::*)(), int X> class IT8 {};
88 template <typename T, void (*)()> class IT9 {};
90 // explicit instantiations
92 // public
93 template class IT1<TestClass::PublicClass>;
94 template struct IT1<TestClass::TemplatePublicClass<int>>;
95 template class IT1<TestClass::AliasPublicClass>;
96 template struct IT2<TestClass::PublicClass, TestClass::PublicClass>;
97 template class IT3<TestClass::publicStaticInt>;
98 template struct IT4<&TestClass::publicFunc>;
99 template class IT4<&TestClass::publicFuncOverloaded>;
100 template class IT5<&TestClass::publicStaticFunc>;
101 template class IT5<&TestClass::publicStaticFuncOverloaded>;
102 template class IT5<&globalFunction>;
103 template class IT6<TestClass::PublicClass>::template NIT1<TestClass::PublicClass>;
104 template class IT7<TestClass::AliasPublicClass, TestClass::PublicClass>;
105 template struct IT7<TestClass::PublicClass, TestClass::TemplatePublicClass<TestClass::PublicClass>>;
106 template class IT8<&TestClass::publicFunc, TestClass::publicStaticInt>;
107 template class IT8<&TestClass::publicFuncOverloaded, TestClass::publicStaticInt>;
108 template class IT9<TestClass::PublicClass, &TestClass::publicStaticFunc>;
109 template class IT9<TestClass::PublicClass, &TestClass::publicStaticFuncOverloaded>;
110 template class IT9<TestClass::PublicClass, &globalFunction>;
112 // protected
113 template class IT1<TestClass::ProtectedClass>;
114 template struct IT1<TestClass::TemplateProtectedClass<int>>;
115 template class IT1<TestClass::AliasProtectedClass>;
116 template struct IT2<TestClass::ProtectedClass, TestClass::ProtectedClass>;
117 template class IT3<TestClass::protectedStaticInt>;
118 template struct IT4<&TestClass::protectedFunc>;
119 template class IT4<&TestClass::protectedFuncOverloaded>;
120 template class IT5<&TestClass::protectedStaticFunc>;
121 template class IT5<&TestClass::protectedStaticFuncOverloaded>;
122 template class IT6<TestClass::ProtectedClass>::template NIT1<TestClass::ProtectedClass>;
123 template class IT7<TestClass::AliasProtectedClass, TestClass::ProtectedClass>;
124 template struct IT7<TestClass::ProtectedClass, TestClass::TemplateProtectedClass<TestClass::ProtectedClass>>;
125 template class IT8<&TestClass::protectedFunc, TestClass::protectedStaticInt>;
126 template class IT8<&TestClass::protectedFuncOverloaded, TestClass::protectedStaticInt>;
127 template class IT9<TestClass::ProtectedClass, &TestClass::protectedStaticFunc>;
128 template class IT9<TestClass::ProtectedClass, &TestClass::protectedStaticFuncOverloaded>;
129 template class IT9<TestClass::ProtectedClass, &globalFunction>;
131 // private
132 template class IT1<TestClass::PrivateClass>;
133 template struct IT1<TestClass::TemplatePrivateClass<int>>;
134 template class IT1<TestClass::AliasPrivateClass>;
135 template struct IT2<TestClass::PrivateClass, TestClass::PrivateClass>;
136 template class IT3<TestClass::privateStaticInt>;
137 template struct IT4<&TestClass::privateFunc>;
138 template class IT4<&TestClass::privateFuncOverloaded>;
139 template class IT5<&TestClass::privateStaticFunc>;
140 template class IT5<&TestClass::privateStaticFuncOverloaded>;
141 template class IT6<TestClass::PrivateClass>::template NIT1<TestClass::PrivateClass>;
142 template class IT7<TestClass::AliasPrivateClass, TestClass::PrivateClass>;
143 template struct IT7<TestClass::PrivateClass, TestClass::TemplatePrivateClass<TestClass::PrivateClass>>;
144 template class IT8<&TestClass::privateFunc, TestClass::privateStaticInt>;
145 template class IT8<&TestClass::privateFuncOverloaded, TestClass::privateStaticInt>;
146 template class IT9<TestClass::PrivateClass, &TestClass::privateStaticFunc>;
147 template class IT9<TestClass::PrivateClass, &TestClass::privateStaticFuncOverloaded>;
148 template class IT9<TestClass::PrivateClass, &globalFunction>;
150 //----------------------------------------------------------//
152 // template declarations for full specializations
153 template <typename T> class CT1 {};
154 template <typename T1, typename T2> class CT2 {};
155 template <int X> class CT3 {};
156 template <void (TestClass::*)()> class CT4 {};
157 template <void (*)()> class CT5 {};
158 template <typename T> class CT6 {
159 template <typename NT> class NCT1 {};
160 template <typename NT> class NCT2; // forward declaration
163 // full specializations
165 // public
166 template <> class CT1<TestClass::PublicClass>;
167 template <typename T> class CT1<TestClass::TemplatePublicClass<T>>; // not full but let it be here
168 template <> struct CT1<TestClass::TemplatePublicClass<int>>;
169 template <> class CT1<TestClass::AliasPublicClass>;
170 template <> struct CT2<TestClass::PublicClass, TestClass::PublicClass>;
171 template <> class CT3<TestClass::publicStaticInt>;
172 template <> struct CT4<&TestClass::publicFunc>;
173 template <> class CT4<&TestClass::publicFuncOverloaded>;
174 template <> struct CT5<&TestClass::publicStaticFunc>;
175 template <> class CT5<&TestClass::publicStaticFuncOverloaded>;
176 template <> class CT5<&globalFunction>;
177 template <> template <> class CT6<TestClass::PublicClass>::NCT1<TestClass::PublicClass>;
179 template <> class CT1<TestClass::PublicClass> final {};
180 template <typename T> class CT1<TestClass::TemplatePublicClass<T>> {};
181 template <> class CT1<TestClass::TemplatePublicClass<int>> final {};
182 template <> class CT1<TestClass::AliasPublicClass> {};
183 template <> class CT2<TestClass::PublicClass, TestClass::PublicClass> final {};
184 template <> class CT3<TestClass::publicStaticInt> {};
185 template <> class CT4<&TestClass::publicFunc> final {};
186 template <> class CT4<&TestClass::publicFuncOverloaded> {};
187 template <> class CT5<&TestClass::publicStaticFunc> final {};
188 template <> class CT5<&TestClass::publicStaticFuncOverloaded> {};
189 template <> class CT5<&globalFunction> final {};
190 template <> template <> class CT6<TestClass::PublicClass>::NCT1<TestClass::PublicClass> {};
191 template <> template <typename NT> class CT6<TestClass::PublicClass>::NCT2 final {}; // declaration
193 // protected
194 template <> class CT1<TestClass::ProtectedClass>;
195 template <typename T> class CT1<TestClass::TemplateProtectedClass<T>>; // not full but let it be here
196 template <> class CT1<TestClass::TemplateProtectedClass<int>>;
197 template <> struct CT1<TestClass::AliasProtectedClass>;
198 template <> class CT2<TestClass::ProtectedClass, TestClass::ProtectedClass>;
199 template <> struct CT3<TestClass::protectedStaticInt>;
200 template <> class CT4<&TestClass::protectedFunc>;
201 template <> struct CT4<&TestClass::protectedFuncOverloaded>;
202 template <> class CT5<&TestClass::protectedStaticFunc>;
203 template <> class CT5<&TestClass::protectedStaticFuncOverloaded>;
204 template <> template <> class CT6<TestClass::ProtectedClass>::NCT1<TestClass::ProtectedClass>;
206 template <> class CT1<TestClass::ProtectedClass> {};
207 template <typename T> class CT1<TestClass::TemplateProtectedClass<T>> final {}; // not full but let it be here
208 template <> class CT1<TestClass::TemplateProtectedClass<int>> {};
209 template <> class CT1<TestClass::AliasProtectedClass> final {};
210 template <> class CT2<TestClass::ProtectedClass, TestClass::ProtectedClass> {};
211 template <> class CT3<TestClass::protectedStaticInt> final {};
212 template <> class CT4<&TestClass::protectedFunc> {};
213 template <> class CT4<&TestClass::protectedFuncOverloaded> final {};
214 template <> class CT5<&TestClass::protectedStaticFunc> {};
215 template <> class CT5<&TestClass::protectedStaticFuncOverloaded> final {};
216 template <> template <> class CT6<TestClass::ProtectedClass>::NCT1<TestClass::ProtectedClass> {};
217 template <> template <typename NT> class CT6<TestClass::ProtectedClass>::NCT2 final {}; // declaration
219 // private
220 template <> class CT1<TestClass::PrivateClass>;
221 template <typename T> class CT1<TestClass::TemplatePrivateClass<T>>; // not full but let it be here
222 template <> struct CT1<TestClass::TemplatePrivateClass<int>>;
223 template <> class CT1<TestClass::AliasPrivateClass>;
224 template <> struct CT2<TestClass::PrivateClass, TestClass::PrivateClass>;
225 template <> class CT3<TestClass::privateStaticInt>;
226 template <> struct CT4<&TestClass::privateFunc>;
227 template <> class CT4<&TestClass::privateFuncOverloaded>;
228 template <> class CT5<&TestClass::privateStaticFunc>;
229 template <> class CT5<&TestClass::privateStaticFuncOverloaded>;
230 template <> template <> class CT6<TestClass::PrivateClass>::NCT1<TestClass::PrivateClass>;
232 template <> class CT1<TestClass::PrivateClass> final {};
233 template <typename T> class CT1<TestClass::TemplatePrivateClass<T>> {}; // not full but let it be here
234 template <> class CT1<TestClass::TemplatePrivateClass<int>> final {};
235 template <> class CT1<TestClass::AliasPrivateClass> {};
236 template <> class CT2<TestClass::PrivateClass, TestClass::PrivateClass> final {};
237 template <> class CT3<TestClass::privateStaticInt> {};
238 template <> class CT4<&TestClass::privateFunc> final {}; // PR37424
239 template <> class CT4<&TestClass::privateFuncOverloaded> {}; // PR37424
240 template <> class CT5<&TestClass::privateStaticFunc> final {};
241 template <> class CT5<&TestClass::privateStaticFuncOverloaded> {};
242 template <> template <> class CT6<TestClass::PrivateClass>::NCT1<TestClass::PrivateClass> final {};
243 template <> template <typename NT> class CT6<TestClass::PrivateClass>::NCT2 {}; // declaration
245 //----------------------------------------------------------//
247 // template declarations for full specializations with parents
248 class P1 {};
249 template <typename T> class PCT1 {};
250 template <typename T1, typename T2> class PCT2 {};
251 template <int X> class PCT3 {};
252 template <void (TestClass::*)()> class PCT4 {};
253 template <void (*)()> class PCT5 {};
254 template <typename T> class PCT6 {
255 // expected-note@+1 3{{implicitly declared private here}}
256 template <typename NT> class NPCT1 {};
257 // expected-note@+1 {{template is declared here}}
258 template <typename NT> class NPCT2; // forward declaration
261 // full specializations with parents
263 // protected + public
264 template <> class PCT1<TestClass::PublicClass> : P1 {};
265 template <typename T> class PCT1<TestClass::TemplatePublicClass<T>> : PCT2<TestClass::PublicClass, TestClass::PublicClass> {}; // not full but let it be here
266 template <> struct PCT1<TestClass::TemplatePublicClass<int>> : PCT1<TestClass::AliasPublicClass> {};
267 template <> class PCT1<TestClass::AliasProtectedClass> : PCT2<TestClass::PublicClass, int> {};
268 template <> struct PCT2<TestClass::ProtectedClass, TestClass::PublicClass> : PCT3<TestClass::publicStaticInt> {};
269 template <> class PCT3<TestClass::protectedStaticInt> : PCT4<&TestClass::publicFunc> {};
270 template <> struct PCT4<&TestClass::protectedFunc> : PCT5<&TestClass::publicStaticFunc> {};
271 template <> class PCT4<&TestClass::publicFuncOverloaded> : PCT5<&TestClass::publicStaticFuncOverloaded> {};
272 template <> class PCT5<&TestClass::protectedStaticFunc> : PCT5<&TestClass::publicStaticFuncOverloaded> {};
273 // expected-error@+1 {{is a private member of}}
274 template <> class PCT5<&TestClass::protectedStaticFuncOverloaded> : PCT6<TestClass::PublicClass>::NPCT1<TestClass::PublicClass> {};
275 // expected-error@+2 {{is a protected member of}}
276 // expected-error@+1 {{is a private member of}}
277 template <> class PCT5<&globalFunction> : PCT6<TestClass::ProtectedClass>::NPCT1<int> {};
278 template <> template <typename NT> class PCT6<TestClass::PublicClass>::NPCT2 : P1 {}; // declaration
279 template <> template <> class PCT6<TestClass::PublicClass>::NPCT1<TestClass::ProtectedClass> : PCT6<TestClass::PublicClass>::template NPCT2<int> {};
281 // protected + private
282 template <> class PCT1<TestClass::PrivateClass> : P1 {};
283 // expected-error@+2 {{is a protected member of}}
284 // expected-error@+1 {{is a private member of}}
285 template <typename T> class PCT1<TestClass::TemplatePrivateClass<T>> : PCT2<TestClass::PrivateClass, TestClass::ProtectedClass> {}; // not full but let it be here
286 // expected-error@+1 {{is a protected member of}}
287 template <> class PCT1<TestClass::TemplatePrivateClass<int>> : PCT1<TestClass::AliasProtectedClass> {};
288 // expected-error@+2 {{is a protected member of}}
289 // expected-error@+1 {{is a private member of}}
290 template <> class PCT1<TestClass::AliasPrivateClass> : PCT2<TestClass::ProtectedClass, TestClass::PrivateClass> {};
291 // expected-error@+1 {{is a protected member of}}
292 template <> class PCT2<TestClass::PrivateClass, TestClass::PrivateClass> : PCT3<TestClass::protectedStaticInt> {};
293 // expected-error@+1 {{is a protected member of}}
294 template <> class PCT3<TestClass::privateStaticInt> : PCT4<&TestClass::protectedFunc> {};
295 // expected-error@+1 {{is a protected member of}}
296 template <> class PCT4<&TestClass::privateFunc> : PCT5<&TestClass::protectedStaticFunc> {};
297 // expected-error@+1 {{is a protected member of}}
298 template <> class PCT4<&TestClass::privateFuncOverloaded> : PCT5<&TestClass::protectedStaticFuncOverloaded> {};
299 template <> class PCT5<&TestClass::privateStaticFunc> : P1 {};
300 // expected-error@+2 {{implicit instantiation of undefined template}}
301 // expected-error@+1 {{is a private member of}}
302 template <> template <> class PCT6<TestClass::PrivateClass>::NPCT1<TestClass::PrivateClass> : PCT6<TestClass::PrivateClass>::NPCT2<int> {};
303 // expected-error@+1 3{{is a private member of}}
304 template <> class PCT5<&TestClass::privateStaticFuncOverloaded> : PCT6<TestClass::PrivateClass>::NPCT1<TestClass::PrivateClass> {};
305 template <> template <typename NT> class PCT6<TestClass::PrivateClass>::NPCT2 : P1 {}; // declaration
307 //----------------------------------------------------------//
309 // template declarations for partial specializations
310 template <typename T1, typename T2> class CTT1 {};
311 template <typename T1, typename T2, typename T3> class CTT2 {};
312 template <typename T, int X> class CTT3 {};
313 template <typename T, void (TestClass::*)()> class CTT4 {};
314 template <typename T, void (*)()> class CTT5 {};
315 template <typename T1, typename T2> class CTT6 {
316 template <typename NT> class NCT1 {};
317 template <typename NT> class NCT2; // forward declaration
318 template <typename NT1, typename NT2> class NCT3 {};
319 template <typename NT1, typename NT2> class NCT4; // forward declaration
322 // partial specializations
324 // public
325 template <typename T> class CTT1<T, TestClass::PublicClass> final {};
326 template <typename T> class CTT1<T, TestClass::TemplatePublicClass<T>> {};
327 template <typename T> struct CTT1<T, TestClass::TemplatePublicClass<int>> final {};
328 template <typename T> class CTT1<T, TestClass::AliasPublicClass> {};
329 template <typename T> struct CTT2<T, TestClass::PublicClass, TestClass::PublicClass> final {};
330 template <typename T> struct CTT2<TestClass::PublicClass, T, TestClass::PublicClass> {};
331 template <typename T> class CTT2<TestClass::PublicClass, TestClass::PublicClass, T> final {};
332 template <typename T> class CTT3<T, TestClass::publicStaticInt> {};
333 template <typename T> class CTT4<T, &TestClass::publicFunc> final {};
334 template <typename T> class CTT4<T, &TestClass::publicFuncOverloaded> {};
335 template <typename T> class CTT5<T, &TestClass::publicStaticFunc> final {};
336 template <typename T> class CTT5<T, &TestClass::publicStaticFuncOverloaded> {};
337 template <typename T> class CTT5<T, &globalFunction> final {};
338 // expected-error@+1 {{cannot specialize a dependent template}}
339 template <typename T1> template <typename T2> class CTT6<T1, TestClass::PublicClass>::template NCT1<T2 *> {};
340 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT1<T3 *> final {};
341 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT2 {}; // declaration
342 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT2<T3 *> final {};
343 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT3<T3, TestClass::PublicClass> {};
344 // expected-error@+1 {{cannot specialize a dependent template}}
345 template <typename T1> template <typename T2> class CTT6<T1, TestClass::PublicClass>::template NCT3<T2, TestClass::PublicClass> final {};
346 template <typename T1, typename T2> template <typename T3, typename T4> class CTT6<T1, T2>::NCT4 {}; // declaration
347 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT4<T3, TestClass::PublicClass> final {};
348 template <typename T> class CTT6<TestClass::PublicClass, T> {
349 template <typename T1, typename T2> class NCT3 {};
350 template <typename T1, typename T2> class NCT4;
352 template <typename T1> template <typename T2> class CTT6<TestClass::PublicClass, T1>::NCT3<T2, TestClass::PublicClass> {};
353 template <typename T1> template <typename, typename> class CTT6<TestClass::PublicClass, T1>::NCT4 final {};
354 template <typename T1> template <typename T2> class CTT6<TestClass::PublicClass, T1>::NCT4<T2, TestClass::PublicClass> {};
356 // protected
358 template <typename T> class CTT1<T, TestClass::ProtectedClass> {};
359 template <typename T> class CTT1<T, TestClass::TemplateProtectedClass<T>> final {};
360 template <typename T> struct CTT1<T, TestClass::TemplateProtectedClass<int>> {};
361 template <typename T> class CTT1<T, TestClass::AliasProtectedClass> final {};
362 template <typename T> struct CTT2<T, TestClass::ProtectedClass, TestClass::ProtectedClass> {};
363 template <typename T> class CTT2<TestClass::ProtectedClass, T, TestClass::ProtectedClass> final {};
364 template <typename T> struct CTT2<TestClass::ProtectedClass, TestClass::ProtectedClass, T> {};
365 template <typename T> class CTT3<T, TestClass::protectedStaticInt> final {};
366 template <typename T> class CTT4<T, &TestClass::protectedFunc> {};
367 template <typename T> class CTT4<T, &TestClass::protectedFuncOverloaded> final {};
368 template <typename T> class CTT5<T, &TestClass::protectedStaticFunc> {};
369 template <typename T> class CTT5<T, &TestClass::protectedStaticFuncOverloaded> final {};
370 // expected-error@+1 {{cannot specialize a dependent template}}
371 template <typename T1> template <typename T2> class CTT6<T1, TestClass::ProtectedClass>::template NCT1<T2 *> {};
372 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT3<T3, TestClass::ProtectedClass> final {};
373 // expected-error@+1 {{cannot specialize a dependent template}}
374 template <typename T1> template <typename T2> class CTT6<T1, TestClass::ProtectedClass>::template NCT3<T2, TestClass::ProtectedClass> {};
375 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT4<T3, TestClass::ProtectedClass> final {};
376 template <typename T> class CTT6<TestClass::ProtectedClass, T> {
377 template <typename T1, typename T2> class NCT3 {};
378 template <typename T1, typename T2> class NCT4;
380 template <typename T1> template <typename T2> class CTT6<TestClass::ProtectedClass, T1>::NCT3<T2, TestClass::ProtectedClass> final {};
381 template <typename T1> template <typename, typename> class CTT6<TestClass::ProtectedClass, T1>::NCT4 {};
382 template <typename T1> template <typename T2> class CTT6<TestClass::ProtectedClass, T1>::NCT4<T2, TestClass::ProtectedClass> final {};
384 // private
386 template <typename T> class CTT1<T, TestClass::PrivateClass> final {};
387 template <typename T> class CTT1<T, TestClass::TemplatePrivateClass<T>> {};
388 template <typename T> struct CTT1<T, TestClass::TemplatePrivateClass<int>> final {};
389 template <typename T> class CTT1<T, TestClass::AliasPrivateClass> {};
390 template <typename T> struct CTT2<T, TestClass::PrivateClass, TestClass::PrivateClass> final {};
391 template <typename T> class CTT2<TestClass::PrivateClass, T, TestClass::PrivateClass> {};
392 template <typename T> struct CTT2<TestClass::PrivateClass, TestClass::PrivateClass, T> final {};
393 template <typename T> class CTT3<T, TestClass::privateStaticInt> {};
394 template <typename T> class CTT4<T, &TestClass::privateFunc> final {};
395 template <typename T> class CTT4<T, &TestClass::privateFuncOverloaded> {};
396 template <typename T> class CTT5<T, &TestClass::privateStaticFunc> final {};
397 template <typename T> class CTT5<T, &TestClass::privateStaticFuncOverloaded> {};
398 // expected-error@+1 {{cannot specialize a dependent template}}
399 template <typename T1> template <typename T2> class CTT6<T1, TestClass::PrivateClass>::template NCT1<T2 *> final {};
400 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT3<T3, TestClass::PrivateClass> {};
401 // expected-error@+1 {{cannot specialize a dependent template}}
402 template <typename T1> template <typename T2> class CTT6<T1, TestClass::PrivateClass>::template NCT3<T2, TestClass::PrivateClass> final {};
403 template <typename T1, typename T2> template <typename T3> class CTT6<T1, T2>::NCT4<T3, TestClass::PrivateClass> {};
404 template <typename T> class CTT6<TestClass::PrivateClass, T> {
405 template <typename T1, typename T2> class NCT3 {};
406 template <typename T1, typename T2> class NCT4;
408 template <typename T1> template <typename T2> class CTT6<TestClass::PrivateClass, T1>::NCT3<T2, TestClass::PrivateClass> {};
409 template <typename T1> template <typename, typename> class CTT6<TestClass::PrivateClass, T1>::NCT4 final {};
410 template <typename T1> template <typename T2> class CTT6<TestClass::PrivateClass, T1>::NCT4<T2, TestClass::PrivateClass> final {};
412 //----------------------------------------------------------//
414 // template declarations for partial specializations with parents
415 template <typename T1, typename T2> class PCTT1 {};
416 template <typename T1, typename T2, typename T3> class PCTT2 {};
417 template <typename T, int X> class PCTT3 {};
418 template <typename T, void (TestClass::*)()> class PCTT4 {};
419 template <typename T, void (*)()> class PCTT5 {};
420 template <typename T1, typename T2> class PCTT6 {
421 template <typename NT> class NCT1 {};
422 template <typename NT> class NCT2; // forward declaration
423 template <typename NT1, typename NT2> class NCT3 {};
424 template <typename NT1, typename NT2> class NCT4; // forward declaration
427 // partial specializations with parents
429 // protected + public
430 template <typename T> class PCTT1<T, TestClass::PublicClass> : P1 {};
431 template <typename T> struct PCTT1<T, TestClass::TemplatePublicClass<T>> final : PCTT2<T, TestClass::PublicClass, TestClass::PublicClass> {}; // not full but let it be here
432 template <typename T> class PCTT1<T, TestClass::TemplatePublicClass<int>> : PCTT1<T, TestClass::AliasPublicClass> {};
433 // expected-error@+1 {{is a protected member of}}
434 template <typename T> class PCTT1<T, TestClass::TemplatePublicClass<TestClass::TemplateProtectedClass<T>>> final : PCTT1<T, TestClass::ProtectedClass> {};
435 template <typename T> struct PCTT1<T, TestClass::AliasProtectedClass> : PCTT2<T, TestClass::PublicClass, int> {};
436 template <typename T> class PCTT2<T, TestClass::ProtectedClass, TestClass::PublicClass> final : PCTT3<T, TestClass::publicStaticInt> {};
437 template <typename T> class PCTT3<T, TestClass::protectedStaticInt> : PCTT4<T, &TestClass::publicFunc> {};
438 template <typename T> struct PCTT4<T, &TestClass::protectedFunc> final : PCTT5<T, &TestClass::publicStaticFunc> {};
439 template <typename T> class PCTT4<T, &TestClass::publicFuncOverloaded> : PCTT5<T, &TestClass::publicStaticFuncOverloaded> {};
440 template <typename T> class PCTT5<T, &TestClass::protectedStaticFunc> final : PCTT5<T, &TestClass::publicStaticFuncOverloaded> {};
441 template <typename T> class PCTT5<T, &TestClass::protectedStaticFuncOverloaded> : PCTT6<T, TestClass::PublicClass>::template NCT1<TestClass::PublicClass> {};
442 // expected-error@+1 {{is a protected member of}}
443 template <typename T> class PCTT5<T, &globalFunction> : PCTT6<T, TestClass::ProtectedClass>::template NCT1<int> {};
444 // expected-error@+1 {{is a protected member of}}
445 template <typename T1, typename T2> template <typename T3> class PCTT6<T1, T2>::NCT2 final : PCTT4<T1, &TestClass::protectedFunc> {}; // declaration
446 template <typename T1, typename T2> template <typename T3> class PCTT6<T1, T2>::NCT2<T3 *> : P1 {};
447 // expected-error@+2 {{cannot specialize a dependent template}}
448 // expected-error@+1 {{is a protected member of}}
449 template <typename T> template <typename NT> class PCTT6<T, TestClass::ProtectedClass>::template NCT1<NT *> : PCTT6<T, TestClass::ProtectedClass>::template NCT2<int> {};
451 // protected + private
452 template <typename T> class PCTT1<T, TestClass::PrivateClass> : P1 {};
453 // expected-error@+2 {{is a protected member of}}
454 // expected-error@+1 {{is a private member of}}
455 template <typename T> struct PCTT1<T, TestClass::TemplatePrivateClass<T>> final : PCTT2<T, TestClass::PrivateClass, TestClass::ProtectedClass> {}; // not full but let it be here
456 // expected-error@+1 {{is a protected member of}}
457 template <typename T> class PCTT1<T, TestClass::TemplatePrivateClass<int>> : PCTT1<T, TestClass::AliasProtectedClass> {};
458 // expected-error@+2 {{is a protected member of}}
459 // expected-error@+1 {{is a private member of}}
460 template <typename T> struct PCTT1<T, TestClass::AliasPrivateClass> final : PCTT2<T, TestClass::ProtectedClass, TestClass::PrivateClass> {};
461 // expected-error@+1 {{is a protected member of}}
462 template <typename T> class PCTT2<T, TestClass::PrivateClass, TestClass::TemplatePrivateClass<T>> : PCTT3<T, TestClass::protectedStaticInt> {};
463 // expected-error@+1 {{is a protected member of}}
464 template <typename T> class PCTT3<T, TestClass::privateStaticInt> final : PCTT4<T, &TestClass::protectedFunc> {};
465 // expected-error@+1 {{is a protected member of}}
466 template <typename T> struct PCTT4<T, &TestClass::privateFunc> : PCTT5<T, &TestClass::protectedStaticFunc> {};
467 // expected-error@+1 {{is a protected member of}}
468 template <typename T> class PCTT4<T, &TestClass::privateFuncOverloaded> final : PCTT5<T, &TestClass::protectedStaticFuncOverloaded> {};
469 template <typename T> class PCTT5<T, &TestClass::privateStaticFunc> : P1 {};
470 // expected-error@+2 {{cannot specialize a dependent template}}
471 // expected-error@+1 {{is a private member of}}
472 template <typename T> class PCTT6<T, TestClass::PrivateClass>::template PCTT1<TestClass::PrivateClass> : PCTT6<T, TestClass::PrivateClass>::template NCT2<int> {};
473 // expected-error@+1 {{is a private member of}}
474 template <typename T> class PCTT5<T, &TestClass::privateStaticFuncOverloaded> final : PCTT6<T, T>::template NCT1<TestClass::PrivateClass> {};
475 template <typename T> class PCTT6<TestClass::PrivateClass, T> {
476 template <typename T1, typename T2> class NCT3 final {};
477 template <typename T1, typename T2> class NCT4;
479 template <typename T1> template <typename, typename> class PCTT6<TestClass::PrivateClass, T1>::NCT4 final {};
480 // expected-error@+1 2{{is a private member of}}
481 template <typename T1> template <typename T2> struct PCTT6<TestClass::PrivateClass, T1>::NCT3<T2, TestClass::TemplatePrivateClass<TestClass::TemplateProtectedClass<TestClass::PublicClass>>> : PCTT6<TestClass::PrivateClass, T1>::NCT4<T2, TestClass::TemplatePrivateClass<int>> {};