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