annotate clang/test/SemaTemplate/temp_class_spec.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 79ff65ed7e25
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2 template<typename T>
anatofuz
parents:
diff changeset
3 struct is_pointer {
anatofuz
parents:
diff changeset
4 static const bool value = false;
anatofuz
parents:
diff changeset
5 };
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 template<typename T>
anatofuz
parents:
diff changeset
8 struct is_pointer<T*> {
anatofuz
parents:
diff changeset
9 static const bool value = true;
anatofuz
parents:
diff changeset
10 };
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 template<typename T>
anatofuz
parents:
diff changeset
13 struct is_pointer<const T*> {
anatofuz
parents:
diff changeset
14 static const bool value = true;
anatofuz
parents:
diff changeset
15 };
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 int array0[is_pointer<int>::value? -1 : 1];
anatofuz
parents:
diff changeset
18 int array1[is_pointer<int*>::value? 1 : -1];
anatofuz
parents:
diff changeset
19 int array2[is_pointer<const int*>::value? 1 : -1];
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 template<typename T>
anatofuz
parents:
diff changeset
22 struct is_lvalue_reference {
anatofuz
parents:
diff changeset
23 static const bool value = false;
anatofuz
parents:
diff changeset
24 };
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 template<typename T>
anatofuz
parents:
diff changeset
27 struct is_lvalue_reference<T&> {
anatofuz
parents:
diff changeset
28 static const bool value = true;
anatofuz
parents:
diff changeset
29 };
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 int lvalue_ref0[is_lvalue_reference<int>::value? -1 : 1];
anatofuz
parents:
diff changeset
32 int lvalue_ref1[is_lvalue_reference<const int&>::value? 1 : -1];
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 template<typename T>
anatofuz
parents:
diff changeset
35 struct is_const {
anatofuz
parents:
diff changeset
36 static const bool value = false;
anatofuz
parents:
diff changeset
37 };
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 template<typename T>
anatofuz
parents:
diff changeset
40 struct is_const<const T> {
anatofuz
parents:
diff changeset
41 static const bool value = true;
anatofuz
parents:
diff changeset
42 };
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 int is_const0[is_const<int>::value? -1 : 1];
anatofuz
parents:
diff changeset
45 int is_const1[is_const<const int>::value? 1 : -1];
anatofuz
parents:
diff changeset
46 int is_const2[is_const<const volatile int>::value? 1 : -1];
anatofuz
parents:
diff changeset
47 int is_const3[is_const<const int [3]>::value? 1 : -1];
anatofuz
parents:
diff changeset
48 int is_const4[is_const<const volatile int[3]>::value? 1 : -1];
anatofuz
parents:
diff changeset
49 int is_const5[is_const<volatile int[3]>::value? -1 : 1];
anatofuz
parents:
diff changeset
50
anatofuz
parents:
diff changeset
51 template<typename T>
anatofuz
parents:
diff changeset
52 struct is_volatile {
anatofuz
parents:
diff changeset
53 static const bool value = false;
anatofuz
parents:
diff changeset
54 };
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 template<typename T>
anatofuz
parents:
diff changeset
57 struct is_volatile<volatile T> {
anatofuz
parents:
diff changeset
58 static const bool value = true;
anatofuz
parents:
diff changeset
59 };
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 int is_volatile0[is_volatile<int>::value? -1 : 1];
anatofuz
parents:
diff changeset
62 int is_volatile1[is_volatile<volatile int>::value? 1 : -1];
anatofuz
parents:
diff changeset
63 int is_volatile2[is_volatile<const volatile int>::value? 1 : -1];
anatofuz
parents:
diff changeset
64 int is_volatile3[is_volatile<volatile char[3]>::value? 1 : -1];
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 template<typename T, typename U>
anatofuz
parents:
diff changeset
67 struct is_same {
anatofuz
parents:
diff changeset
68 static const bool value = false;
anatofuz
parents:
diff changeset
69 };
anatofuz
parents:
diff changeset
70
anatofuz
parents:
diff changeset
71 template<typename T>
anatofuz
parents:
diff changeset
72 struct is_same<T, T> {
anatofuz
parents:
diff changeset
73 static const bool value = true;
anatofuz
parents:
diff changeset
74 };
anatofuz
parents:
diff changeset
75
anatofuz
parents:
diff changeset
76 typedef int INT;
anatofuz
parents:
diff changeset
77 typedef INT* int_ptr;
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 int is_same0[is_same<int, int>::value? 1 : -1];
anatofuz
parents:
diff changeset
80 int is_same1[is_same<int, INT>::value? 1 : -1];
anatofuz
parents:
diff changeset
81 int is_same2[is_same<const int, int>::value? -1 : 1];
anatofuz
parents:
diff changeset
82 int is_same3[is_same<int_ptr, int>::value? -1 : 1];
anatofuz
parents:
diff changeset
83
anatofuz
parents:
diff changeset
84 template<typename T>
anatofuz
parents:
diff changeset
85 struct remove_reference {
anatofuz
parents:
diff changeset
86 typedef T type;
anatofuz
parents:
diff changeset
87 };
anatofuz
parents:
diff changeset
88
anatofuz
parents:
diff changeset
89 template<typename T>
anatofuz
parents:
diff changeset
90 struct remove_reference<T&> {
anatofuz
parents:
diff changeset
91 typedef T type;
anatofuz
parents:
diff changeset
92 };
anatofuz
parents:
diff changeset
93
anatofuz
parents:
diff changeset
94 int remove_ref0[is_same<remove_reference<int>::type, int>::value? 1 : -1];
anatofuz
parents:
diff changeset
95 int remove_ref1[is_same<remove_reference<int&>::type, int>::value? 1 : -1];
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 template<typename T>
anatofuz
parents:
diff changeset
98 struct remove_const {
anatofuz
parents:
diff changeset
99 typedef T type;
anatofuz
parents:
diff changeset
100 };
anatofuz
parents:
diff changeset
101
anatofuz
parents:
diff changeset
102 template<typename T>
anatofuz
parents:
diff changeset
103 struct remove_const<const T> {
anatofuz
parents:
diff changeset
104 typedef T type;
anatofuz
parents:
diff changeset
105 };
anatofuz
parents:
diff changeset
106
anatofuz
parents:
diff changeset
107 int remove_const0[is_same<remove_const<const int>::type, int>::value? 1 : -1];
anatofuz
parents:
diff changeset
108 int remove_const1[is_same<remove_const<const int[3]>::type, int[3]>::value? 1 : -1];
anatofuz
parents:
diff changeset
109
anatofuz
parents:
diff changeset
110 template<typename T>
anatofuz
parents:
diff changeset
111 struct is_incomplete_array {
anatofuz
parents:
diff changeset
112 static const bool value = false;
anatofuz
parents:
diff changeset
113 };
anatofuz
parents:
diff changeset
114
anatofuz
parents:
diff changeset
115 template<typename T>
anatofuz
parents:
diff changeset
116 struct is_incomplete_array<T[]> {
anatofuz
parents:
diff changeset
117 static const bool value = true;
anatofuz
parents:
diff changeset
118 };
anatofuz
parents:
diff changeset
119
anatofuz
parents:
diff changeset
120 int incomplete_array0[is_incomplete_array<int>::value ? -1 : 1];
anatofuz
parents:
diff changeset
121 int incomplete_array1[is_incomplete_array<int[1]>::value ? -1 : 1];
anatofuz
parents:
diff changeset
122 int incomplete_array2[is_incomplete_array<bool[]>::value ? 1 : -1];
anatofuz
parents:
diff changeset
123 int incomplete_array3[is_incomplete_array<int[]>::value ? 1 : -1];
anatofuz
parents:
diff changeset
124
anatofuz
parents:
diff changeset
125 template<typename T>
anatofuz
parents:
diff changeset
126 struct is_array_with_4_elements {
anatofuz
parents:
diff changeset
127 static const bool value = false;
anatofuz
parents:
diff changeset
128 };
anatofuz
parents:
diff changeset
129
anatofuz
parents:
diff changeset
130 template<typename T>
anatofuz
parents:
diff changeset
131 struct is_array_with_4_elements<T[4]> {
anatofuz
parents:
diff changeset
132 static const bool value = true;
anatofuz
parents:
diff changeset
133 };
anatofuz
parents:
diff changeset
134
anatofuz
parents:
diff changeset
135 int array_with_4_elements0[is_array_with_4_elements<int[]>::value ? -1 : 1];
anatofuz
parents:
diff changeset
136 int array_with_4_elements1[is_array_with_4_elements<int[1]>::value ? -1 : 1];
anatofuz
parents:
diff changeset
137 int array_with_4_elements2[is_array_with_4_elements<int[4]>::value ? 1 : -1];
anatofuz
parents:
diff changeset
138 int array_with_4_elements3[is_array_with_4_elements<int[4][2]>::value ? 1 : -1];
anatofuz
parents:
diff changeset
139
anatofuz
parents:
diff changeset
140 template<typename T>
anatofuz
parents:
diff changeset
141 struct get_array_size;
anatofuz
parents:
diff changeset
142
anatofuz
parents:
diff changeset
143 template<typename T, unsigned N>
anatofuz
parents:
diff changeset
144 struct get_array_size<T[N]> {
anatofuz
parents:
diff changeset
145 static const unsigned value = N;
anatofuz
parents:
diff changeset
146 };
anatofuz
parents:
diff changeset
147
anatofuz
parents:
diff changeset
148 int array_size0[get_array_size<int[12]>::value == 12? 1 : -1];
anatofuz
parents:
diff changeset
149
anatofuz
parents:
diff changeset
150 template<typename T>
anatofuz
parents:
diff changeset
151 struct remove_extent {
anatofuz
parents:
diff changeset
152 typedef T type;
anatofuz
parents:
diff changeset
153 };
anatofuz
parents:
diff changeset
154
anatofuz
parents:
diff changeset
155 template<typename T>
anatofuz
parents:
diff changeset
156 struct remove_extent<T[]> {
anatofuz
parents:
diff changeset
157 typedef T type;
anatofuz
parents:
diff changeset
158 };
anatofuz
parents:
diff changeset
159
anatofuz
parents:
diff changeset
160 template<typename T, unsigned N>
anatofuz
parents:
diff changeset
161 struct remove_extent<T[N]> {
anatofuz
parents:
diff changeset
162 typedef T type;
anatofuz
parents:
diff changeset
163 };
anatofuz
parents:
diff changeset
164
anatofuz
parents:
diff changeset
165 int remove_extent0[is_same<remove_extent<int[][5]>::type, int[5]>::value? 1 : -1];
anatofuz
parents:
diff changeset
166 int remove_extent1[is_same<remove_extent<const int[][5]>::type, const int[5]>::value? 1 : -1];
anatofuz
parents:
diff changeset
167
anatofuz
parents:
diff changeset
168 template<typename T>
anatofuz
parents:
diff changeset
169 struct is_unary_function {
anatofuz
parents:
diff changeset
170 static const bool value = false;
anatofuz
parents:
diff changeset
171 };
anatofuz
parents:
diff changeset
172
anatofuz
parents:
diff changeset
173 template<typename T, typename U>
anatofuz
parents:
diff changeset
174 struct is_unary_function<T (*)(U)> {
anatofuz
parents:
diff changeset
175 static const bool value = true;
anatofuz
parents:
diff changeset
176 };
anatofuz
parents:
diff changeset
177
anatofuz
parents:
diff changeset
178 int is_unary_function0[is_unary_function<int>::value ? -1 : 1];
anatofuz
parents:
diff changeset
179 int is_unary_function1[is_unary_function<int (*)()>::value ? -1 : 1];
anatofuz
parents:
diff changeset
180 int is_unary_function2[is_unary_function<int (*)(int, bool)>::value ? -1 : 1];
anatofuz
parents:
diff changeset
181 int is_unary_function3[is_unary_function<int (*)(bool)>::value ? 1 : -1];
anatofuz
parents:
diff changeset
182 int is_unary_function4[is_unary_function<int (*)(int)>::value ? 1 : -1];
anatofuz
parents:
diff changeset
183
anatofuz
parents:
diff changeset
184 template<typename T>
anatofuz
parents:
diff changeset
185 struct is_unary_function_with_same_return_type_as_argument_type {
anatofuz
parents:
diff changeset
186 static const bool value = false;
anatofuz
parents:
diff changeset
187 };
anatofuz
parents:
diff changeset
188
anatofuz
parents:
diff changeset
189 template<typename T>
anatofuz
parents:
diff changeset
190 struct is_unary_function_with_same_return_type_as_argument_type<T (*)(T)> {
anatofuz
parents:
diff changeset
191 static const bool value = true;
anatofuz
parents:
diff changeset
192 };
anatofuz
parents:
diff changeset
193
anatofuz
parents:
diff changeset
194 int is_unary_function5[is_unary_function_with_same_return_type_as_argument_type<int>::value ? -1 : 1];
anatofuz
parents:
diff changeset
195 int is_unary_function6[is_unary_function_with_same_return_type_as_argument_type<int (*)()>::value ? -1 : 1];
anatofuz
parents:
diff changeset
196 int is_unary_function7[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, bool)>::value ? -1 : 1];
anatofuz
parents:
diff changeset
197 int is_unary_function8[is_unary_function_with_same_return_type_as_argument_type<int (*)(bool)>::value ? -1 : 1];
anatofuz
parents:
diff changeset
198 int is_unary_function9[is_unary_function_with_same_return_type_as_argument_type<int (*)(int)>::value ? 1 : -1];
anatofuz
parents:
diff changeset
199 int is_unary_function10[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, ...)>::value ? -1 : 1];
anatofuz
parents:
diff changeset
200 int is_unary_function11[is_unary_function_with_same_return_type_as_argument_type<int (* const)(int)>::value ? -1 : 1];
anatofuz
parents:
diff changeset
201
anatofuz
parents:
diff changeset
202 template<typename T>
anatofuz
parents:
diff changeset
203 struct is_binary_function {
anatofuz
parents:
diff changeset
204 static const bool value = false;
anatofuz
parents:
diff changeset
205 };
anatofuz
parents:
diff changeset
206
anatofuz
parents:
diff changeset
207 template<typename R, typename T1, typename T2>
anatofuz
parents:
diff changeset
208 struct is_binary_function<R(T1, T2)> {
anatofuz
parents:
diff changeset
209 static const bool value = true;
anatofuz
parents:
diff changeset
210 };
anatofuz
parents:
diff changeset
211
anatofuz
parents:
diff changeset
212 int is_binary_function0[is_binary_function<int(float, double)>::value? 1 : -1];
anatofuz
parents:
diff changeset
213
anatofuz
parents:
diff changeset
214 template<typename T>
anatofuz
parents:
diff changeset
215 struct is_member_pointer {
anatofuz
parents:
diff changeset
216 static const bool value = false;
anatofuz
parents:
diff changeset
217 };
anatofuz
parents:
diff changeset
218
anatofuz
parents:
diff changeset
219 template<typename T, typename Class>
anatofuz
parents:
diff changeset
220 struct is_member_pointer<T Class::*> {
anatofuz
parents:
diff changeset
221 static const bool value = true;
anatofuz
parents:
diff changeset
222 };
anatofuz
parents:
diff changeset
223
anatofuz
parents:
diff changeset
224 struct X { };
anatofuz
parents:
diff changeset
225
anatofuz
parents:
diff changeset
226 int is_member_pointer0[is_member_pointer<int X::*>::value? 1 : -1];
anatofuz
parents:
diff changeset
227 int is_member_pointer1[is_member_pointer<const int X::*>::value? 1 : -1];
anatofuz
parents:
diff changeset
228 int is_member_pointer2[is_member_pointer<int (X::*)()>::value? 1 : -1];
anatofuz
parents:
diff changeset
229 int is_member_pointer3[is_member_pointer<int (X::*)(int) const>::value? 1 : -1];
anatofuz
parents:
diff changeset
230 int is_member_pointer4[is_member_pointer<int (X::**)(int) const>::value? -1 : 1];
anatofuz
parents:
diff changeset
231 int is_member_pointer5[is_member_pointer<int>::value? -1 : 1];
anatofuz
parents:
diff changeset
232
anatofuz
parents:
diff changeset
233 template<typename T>
anatofuz
parents:
diff changeset
234 struct is_member_function_pointer {
anatofuz
parents:
diff changeset
235 static const bool value = false;
anatofuz
parents:
diff changeset
236 };
anatofuz
parents:
diff changeset
237
anatofuz
parents:
diff changeset
238 template<typename T, typename Class>
anatofuz
parents:
diff changeset
239 struct is_member_function_pointer<T (Class::*)()> {
anatofuz
parents:
diff changeset
240 static const bool value = true;
anatofuz
parents:
diff changeset
241 };
anatofuz
parents:
diff changeset
242
anatofuz
parents:
diff changeset
243 template<typename T, typename Class>
anatofuz
parents:
diff changeset
244 struct is_member_function_pointer<T (Class::*)() const> {
anatofuz
parents:
diff changeset
245 static const bool value = true;
anatofuz
parents:
diff changeset
246 };
anatofuz
parents:
diff changeset
247
anatofuz
parents:
diff changeset
248 template<typename T, typename Class>
anatofuz
parents:
diff changeset
249 struct is_member_function_pointer<T (Class::*)() volatile> {
anatofuz
parents:
diff changeset
250 static const bool value = true;
anatofuz
parents:
diff changeset
251 };
anatofuz
parents:
diff changeset
252
anatofuz
parents:
diff changeset
253 template<typename T, typename Class>
anatofuz
parents:
diff changeset
254 struct is_member_function_pointer<T (Class::*)() const volatile> {
anatofuz
parents:
diff changeset
255 static const bool value = true;
anatofuz
parents:
diff changeset
256 };
anatofuz
parents:
diff changeset
257
anatofuz
parents:
diff changeset
258 template<typename T, typename Class, typename A1>
anatofuz
parents:
diff changeset
259 struct is_member_function_pointer<T (Class::*)(A1)> {
anatofuz
parents:
diff changeset
260 static const bool value = true;
anatofuz
parents:
diff changeset
261 };
anatofuz
parents:
diff changeset
262
anatofuz
parents:
diff changeset
263 template<typename T, typename Class, typename A1>
anatofuz
parents:
diff changeset
264 struct is_member_function_pointer<T (Class::*)(A1) const> {
anatofuz
parents:
diff changeset
265 static const bool value = true;
anatofuz
parents:
diff changeset
266 };
anatofuz
parents:
diff changeset
267
anatofuz
parents:
diff changeset
268 template<typename T, typename Class, typename A1>
anatofuz
parents:
diff changeset
269 struct is_member_function_pointer<T (Class::*)(A1) volatile> {
anatofuz
parents:
diff changeset
270 static const bool value = true;
anatofuz
parents:
diff changeset
271 };
anatofuz
parents:
diff changeset
272
anatofuz
parents:
diff changeset
273 template<typename T, typename Class, typename A1>
anatofuz
parents:
diff changeset
274 struct is_member_function_pointer<T (Class::*)(A1) const volatile> {
anatofuz
parents:
diff changeset
275 static const bool value = true;
anatofuz
parents:
diff changeset
276 };
anatofuz
parents:
diff changeset
277
anatofuz
parents:
diff changeset
278 int is_member_function_pointer0[
anatofuz
parents:
diff changeset
279 is_member_function_pointer<int X::*>::value? -1 : 1];
anatofuz
parents:
diff changeset
280 int is_member_function_pointer1[
anatofuz
parents:
diff changeset
281 is_member_function_pointer<int (X::*)()>::value? 1 : -1];
anatofuz
parents:
diff changeset
282 int is_member_function_pointer2[
anatofuz
parents:
diff changeset
283 is_member_function_pointer<X (X::*)(X&)>::value? 1 : -1];
anatofuz
parents:
diff changeset
284 int is_member_function_pointer3[
anatofuz
parents:
diff changeset
285 is_member_function_pointer<int (X::*)() const>::value? 1 : -1];
anatofuz
parents:
diff changeset
286 int is_member_function_pointer4[
anatofuz
parents:
diff changeset
287 is_member_function_pointer<int (X::*)(float) const>::value? 1 : -1];
anatofuz
parents:
diff changeset
288
anatofuz
parents:
diff changeset
289 // Test substitution of non-dependent arguments back into the template
anatofuz
parents:
diff changeset
290 // argument list of the class template partial specialization.
anatofuz
parents:
diff changeset
291 template<typename T, typename ValueType = T>
anatofuz
parents:
diff changeset
292 struct is_nested_value_type_identity {
anatofuz
parents:
diff changeset
293 static const bool value = false;
anatofuz
parents:
diff changeset
294 };
anatofuz
parents:
diff changeset
295
anatofuz
parents:
diff changeset
296 template<typename T>
anatofuz
parents:
diff changeset
297 struct is_nested_value_type_identity<T, typename T::value_type> {
anatofuz
parents:
diff changeset
298 static const bool value = true;
anatofuz
parents:
diff changeset
299 };
anatofuz
parents:
diff changeset
300
anatofuz
parents:
diff changeset
301 template<typename T>
anatofuz
parents:
diff changeset
302 struct HasValueType {
anatofuz
parents:
diff changeset
303 typedef T value_type;
anatofuz
parents:
diff changeset
304 };
anatofuz
parents:
diff changeset
305
anatofuz
parents:
diff changeset
306 struct HasIdentityValueType {
anatofuz
parents:
diff changeset
307 typedef HasIdentityValueType value_type;
anatofuz
parents:
diff changeset
308 };
anatofuz
parents:
diff changeset
309
anatofuz
parents:
diff changeset
310 struct NoValueType { };
anatofuz
parents:
diff changeset
311
anatofuz
parents:
diff changeset
312 int is_nested_value_type_identity0[
anatofuz
parents:
diff changeset
313 is_nested_value_type_identity<HasValueType<int> >::value? -1 : 1];
anatofuz
parents:
diff changeset
314 int is_nested_value_type_identity1[
anatofuz
parents:
diff changeset
315 is_nested_value_type_identity<HasIdentityValueType>::value? 1 : -1];
anatofuz
parents:
diff changeset
316 int is_nested_value_type_identity2[
anatofuz
parents:
diff changeset
317 is_nested_value_type_identity<NoValueType>::value? -1 : 1];
anatofuz
parents:
diff changeset
318
anatofuz
parents:
diff changeset
319
anatofuz
parents:
diff changeset
320 // C++ [temp.class.spec]p4:
anatofuz
parents:
diff changeset
321 template<class T1, class T2, int I> class A { }; //#1
anatofuz
parents:
diff changeset
322 template<class T, int I> class A<T, T*, I> { }; //#2
anatofuz
parents:
diff changeset
323 template<class T1, class T2, int I> class A<T1*, T2, I> { }; //#3
anatofuz
parents:
diff changeset
324 template<class T> class A<int, T*, 5> { }; //#4
anatofuz
parents:
diff changeset
325 template<class T1, class T2, int I> class A<T1, T2*, I> { }; //#5
anatofuz
parents:
diff changeset
326
anatofuz
parents:
diff changeset
327 // Redefinition of class template partial specializations
anatofuz
parents:
diff changeset
328 template<typename T, T N, typename U> class A0;
anatofuz
parents:
diff changeset
329
anatofuz
parents:
diff changeset
330 template<typename T, T N> class A0<T, N, int> { }; // expected-note{{here}}
anatofuz
parents:
diff changeset
331 template<typename T, T N> class A0<T, N, int>;
anatofuz
parents:
diff changeset
332 template<typename T, T N> class A0<T, N, int> { }; // expected-error{{redef}}
anatofuz
parents:
diff changeset
333
anatofuz
parents:
diff changeset
334 namespace PR6025 {
anatofuz
parents:
diff changeset
335 template< int N > struct A;
anatofuz
parents:
diff changeset
336
anatofuz
parents:
diff changeset
337 namespace N
anatofuz
parents:
diff changeset
338 {
anatofuz
parents:
diff changeset
339 template< typename F >
anatofuz
parents:
diff changeset
340 struct B;
anatofuz
parents:
diff changeset
341 }
anatofuz
parents:
diff changeset
342
anatofuz
parents:
diff changeset
343 template< typename Protect, typename Second >
anatofuz
parents:
diff changeset
344 struct C;
anatofuz
parents:
diff changeset
345
anatofuz
parents:
diff changeset
346 template <class T>
anatofuz
parents:
diff changeset
347 struct C< T, A< N::B<T>::value > >
anatofuz
parents:
diff changeset
348 {
anatofuz
parents:
diff changeset
349 };
anatofuz
parents:
diff changeset
350 }
anatofuz
parents:
diff changeset
351
anatofuz
parents:
diff changeset
352 namespace PR6181 {
anatofuz
parents:
diff changeset
353 template <class T>
anatofuz
parents:
diff changeset
354 class a;
anatofuz
parents:
diff changeset
355
anatofuz
parents:
diff changeset
356 class s;
anatofuz
parents:
diff changeset
357
anatofuz
parents:
diff changeset
358 template <class U>
anatofuz
parents:
diff changeset
359 class a<s> // expected-error{{partial specialization of 'a' does not use any of its template parameters}}
anatofuz
parents:
diff changeset
360 {
anatofuz
parents:
diff changeset
361 };
anatofuz
parents:
diff changeset
362
anatofuz
parents:
diff changeset
363 }
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
364
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
365 // Check that we do not crash on invalid code that leads to invalid base.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
366 namespace {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
367 template <typename X>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
368 class Foo {};
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
369
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
370 template <int Y>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
371 class Bar;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
372
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
373 template <typename Z>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
374 class Bar<0> : public Foo<Z> { // expected-error{{partial specialization of 'Bar' does not use any of its template parameters}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
375 Bar() : Foo<Z>() {}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
376 };
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
377 } // namespace
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
378
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
379 namespace Crash {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
380 template<typename T>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
381 class Base {};
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
382
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
383 template<typename T> class Foo;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
384
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
385 template <typename T>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
386 class Foo<int> : public Base<T> {}; // expected-error{{partial specialization of 'Foo' does not use any of its template parameters}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
387
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
388 // verify that getASTRecordLayout doesn't crash on the ClassTemplateSpecializationDecl.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
389 constexpr int s = sizeof(Foo<int>);
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
390 }