1 // RUN: clang-cc -fsyntax-only -verify %s
2 template<typename T>
3 struct is_pointer {
4   static const bool value = false;
5 };
6 
7 template<typename T>
8 struct is_pointer<T*> {
9   static const bool value = true;
10 };
11 
12 template<typename T>
13 struct is_pointer<const T*> {
14   static const bool value = true;
15 };
16 
17 int array0[is_pointer<int>::value? -1 : 1];
18 int array1[is_pointer<int*>::value? 1 : -1];
19 int array2[is_pointer<const int*>::value? 1 : -1]; // expected-error{{partial ordering}} \
20 // expected-error{{negative}}
21 
22 template<typename T>
23 struct is_lvalue_reference {
24   static const bool value = false;
25 };
26 
27 template<typename T>
28 struct is_lvalue_reference<T&> {
29   static const bool value = true;
30 };
31 
32 int lvalue_ref0[is_lvalue_reference<int>::value? -1 : 1];
33 int lvalue_ref1[is_lvalue_reference<const int&>::value? 1 : -1];
34 
35 template<typename T>
36 struct is_const {
37   static const bool value = false;
38 };
39 
40 template<typename T>
41 struct is_const<const T> {
42   static const bool value = true;
43 };
44 
45 int is_const0[is_const<int>::value? -1 : 1];
46 int is_const1[is_const<const int>::value? 1 : -1];
47 int is_const2[is_const<const volatile int>::value? 1 : -1];
48 int is_const3[is_const<const int [3]>::value? 1 : -1];
49 int is_const4[is_const<const volatile int[3]>::value? 1 : -1];
50 int is_const4[is_const<volatile int[3]>::value? -1 : 1];
51 
52 template<typename T>
53 struct is_volatile {
54   static const bool value = false;
55 };
56 
57 template<typename T>
58 struct is_volatile<volatile T> {
59   static const bool value = true;
60 };
61 
62 int is_volatile0[is_volatile<int>::value? -1 : 1];
63 int is_volatile1[is_volatile<volatile int>::value? 1 : -1];
64 int is_volatile2[is_volatile<const volatile int>::value? 1 : -1];
65 int is_volatile3[is_volatile<volatile char[3]>::value? 1 : -1];
66 
67 template<typename T, typename U>
68 struct is_same {
69   static const bool value = false;
70 };
71 
72 template<typename T>
73 struct is_same<T, T> {
74   static const bool value = true;
75 };
76 
77 typedef int INT;
78 typedef INT* int_ptr;
79 
80 int is_same0[is_same<int, int>::value? 1 : -1];
81 int is_same1[is_same<int, INT>::value? 1 : -1];
82 int is_same2[is_same<const int, int>::value? -1 : 1];
83 int is_same3[is_same<int_ptr, int>::value? -1 : 1];
84 
85 template<typename T>
86 struct remove_reference {
87   typedef T type;
88 };
89 
90 template<typename T>
91 struct remove_reference<T&> {
92   typedef T type;
93 };
94 
95 int remove_ref0[is_same<remove_reference<int>::type, int>::value? 1 : -1];
96 int remove_ref1[is_same<remove_reference<int&>::type, int>::value? 1 : -1];
97 
98 template<typename T>
99 struct is_incomplete_array {
100   static const bool value = false;
101 };
102 
103 template<typename T>
104 struct is_incomplete_array<T[]> {
105   static const bool value = true;
106 };
107 
108 int incomplete_array0[is_incomplete_array<int>::value ? -1 : 1];
109 int incomplete_array1[is_incomplete_array<int[1]>::value ? -1 : 1];
110 int incomplete_array2[is_incomplete_array<bool[]>::value ? 1 : -1];
111 int incomplete_array3[is_incomplete_array<int[]>::value ? 1 : -1];
112 
113 template<typename T>
114 struct is_array_with_4_elements {
115   static const bool value = false;
116 };
117 
118 template<typename T>
119 struct is_array_with_4_elements<T[4]> {
120   static const bool value = true;
121 };
122 
123 int array_with_4_elements0[is_array_with_4_elements<int[]>::value ? -1 : 1];
124 int array_with_4_elements1[is_array_with_4_elements<int[1]>::value ? -1 : 1];
125 int array_with_4_elements2[is_array_with_4_elements<int[4]>::value ? 1 : -1];
126 int array_with_4_elements3[is_array_with_4_elements<int[4][2]>::value ? 1 : -1];
127 
128 template<typename T>
129 struct get_array_size;
130 
131 template<typename T, unsigned N>
132 struct get_array_size<T[N]> {
133   static const unsigned value = N;
134 };
135 
136 int array_size0[get_array_size<int[12]>::value == 12? 1 : -1];
137 
138 template<typename T>
139 struct is_unary_function {
140   static const bool value = false;
141 };
142 
143 template<typename T, typename U>
144 struct is_unary_function<T (*)(U)> {
145   static const bool value = true;
146 };
147 
148 int is_unary_function0[is_unary_function<int>::value ? -1 : 1];
149 int is_unary_function1[is_unary_function<int (*)()>::value ? -1 : 1];
150 int is_unary_function2[is_unary_function<int (*)(int, bool)>::value ? -1 : 1];
151 int is_unary_function3[is_unary_function<int (*)(bool)>::value ? 1 : -1];
152 int is_unary_function4[is_unary_function<int (*)(int)>::value ? 1 : -1];
153 
154 template<typename T>
155 struct is_unary_function_with_same_return_type_as_argument_type {
156   static const bool value = false;
157 };
158 
159 template<typename T>
160 struct is_unary_function_with_same_return_type_as_argument_type<T (*)(T)> {
161   static const bool value = true;
162 };
163 
164 int is_unary_function5[is_unary_function_with_same_return_type_as_argument_type<int>::value ? -1 : 1];
165 int is_unary_function6[is_unary_function_with_same_return_type_as_argument_type<int (*)()>::value ? -1 : 1];
166 int is_unary_function7[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, bool)>::value ? -1 : 1];
167 int is_unary_function8[is_unary_function_with_same_return_type_as_argument_type<int (*)(bool)>::value ? -1 : 1];
168 int is_unary_function9[is_unary_function_with_same_return_type_as_argument_type<int (*)(int)>::value ? 1 : -1];
169 int is_unary_function10[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, ...)>::value ? -1 : 1];
170 int is_unary_function11[is_unary_function_with_same_return_type_as_argument_type<int (* const)(int)>::value ? -1 : 1];
171 
172 template<typename T>
173 struct is_binary_function {
174   static const bool value = false;
175 };
176 
177 template<typename R, typename T1, typename T2>
178 struct is_binary_function<R(T1, T2)> {
179   static const bool value = true;
180 };
181 
182 int is_binary_function0[is_binary_function<int(float, double)>::value? 1 : -1];
183 
184 template<typename T>
185 struct is_member_pointer {
186   static const bool value = false;
187 };
188 
189 template<typename T, typename Class>
190 struct is_member_pointer<T Class::*> {
191   static const bool value = true;
192 };
193 
194 struct X { };
195 
196 int is_member_pointer0[is_member_pointer<int X::*>::value? 1 : -1];
197 int is_member_pointer1[is_member_pointer<const int X::*>::value? 1 : -1];
198 int is_member_pointer2[is_member_pointer<int (X::*)()>::value? 1 : -1];
199 int is_member_pointer3[is_member_pointer<int (X::*)(int) const>::value? 1 : -1];
200 int is_member_pointer4[is_member_pointer<int (X::**)(int) const>::value? -1 : 1];
201 int is_member_pointer5[is_member_pointer<int>::value? -1 : 1];
202 
203 template<typename T>
204 struct is_member_function_pointer {
205   static const bool value = false;
206 };
207 
208 template<typename T, typename Class>
209 struct is_member_function_pointer<T (Class::*)()> {
210   static const bool value = true;
211 };
212 
213 template<typename T, typename Class>
214 struct is_member_function_pointer<T (Class::*)() const> {
215   static const bool value = true;
216 };
217 
218 template<typename T, typename Class>
219 struct is_member_function_pointer<T (Class::*)() volatile> {
220   static const bool value = true;
221 };
222 
223 template<typename T, typename Class>
224 struct is_member_function_pointer<T (Class::*)() const volatile> {
225   static const bool value = true;
226 };
227 
228 template<typename T, typename Class, typename A1>
229 struct is_member_function_pointer<T (Class::*)(A1)> {
230   static const bool value = true;
231 };
232 
233 template<typename T, typename Class, typename A1>
234 struct is_member_function_pointer<T (Class::*)(A1) const> {
235   static const bool value = true;
236 };
237 
238 template<typename T, typename Class, typename A1>
239 struct is_member_function_pointer<T (Class::*)(A1) volatile> {
240   static const bool value = true;
241 };
242 
243 template<typename T, typename Class, typename A1>
244 struct is_member_function_pointer<T (Class::*)(A1) const volatile> {
245   static const bool value = true;
246 };
247 
248 int is_member_function_pointer0[
249                           is_member_function_pointer<int X::*>::value? -1 : 1];
250 int is_member_function_pointer1[
251                       is_member_function_pointer<int (X::*)()>::value? 1 : -1];
252 int is_member_function_pointer2[
253                       is_member_function_pointer<X (X::*)(X&)>::value? 1 : -1];
254 int is_member_function_pointer3[
255            is_member_function_pointer<int (X::*)() const>::value? 1 : -1];
256 int is_member_function_pointer4[
257            is_member_function_pointer<int (X::*)(float) const>::value? 1 : -1];
258 
259 // Test substitution of non-dependent arguments back into the template
260 // argument list of the class template partial specialization.
261 template<typename T, typename ValueType = T>
262 struct is_nested_value_type_identity {
263   static const bool value = false;
264 };
265 
266 template<typename T>
267 struct is_nested_value_type_identity<T, typename T::value_type> {
268   static const bool value = true;
269 };
270 
271 template<typename T>
272 struct HasValueType {
273   typedef T value_type;
274 };
275 
276 struct HasIdentityValueType {
277   typedef HasIdentityValueType value_type;
278 };
279 
280 struct NoValueType { };
281 
282 int is_nested_value_type_identity0[
283             is_nested_value_type_identity<HasValueType<int> >::value? -1 : 1];
284 int is_nested_value_type_identity1[
285           is_nested_value_type_identity<HasIdentityValueType>::value? 1 : -1];
286 int is_nested_value_type_identity2[
287                    is_nested_value_type_identity<NoValueType>::value? -1 : 1];
288 
289 
290 // C++ [temp.class.spec]p4:
291 template<class T1, class T2, int I> class A { }; //#1
292 template<class T, int I> class A<T, T*, I> { }; //#2
293 template<class T1, class T2, int I> class A<T1*, T2, I> { }; //#3
294 template<class T> class A<int, T*, 5> { }; //#4
295 template<class T1, class T2, int I> class A<T1, T2*, I> { }; //#5
296