From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaTemplate/temp_class_spec.cpp | 363 ++++++++++++++++++++++++++++ 1 file changed, 363 insertions(+) create mode 100644 clang/test/SemaTemplate/temp_class_spec.cpp (limited to 'clang/test/SemaTemplate/temp_class_spec.cpp') diff --git a/clang/test/SemaTemplate/temp_class_spec.cpp b/clang/test/SemaTemplate/temp_class_spec.cpp new file mode 100644 index 0000000..8a07fd7 --- /dev/null +++ b/clang/test/SemaTemplate/temp_class_spec.cpp @@ -0,0 +1,363 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template +struct is_pointer { + static const bool value = false; +}; + +template +struct is_pointer { + static const bool value = true; +}; + +template +struct is_pointer { + static const bool value = true; +}; + +int array0[is_pointer::value? -1 : 1]; +int array1[is_pointer::value? 1 : -1]; +int array2[is_pointer::value? 1 : -1]; + +template +struct is_lvalue_reference { + static const bool value = false; +}; + +template +struct is_lvalue_reference { + static const bool value = true; +}; + +int lvalue_ref0[is_lvalue_reference::value? -1 : 1]; +int lvalue_ref1[is_lvalue_reference::value? 1 : -1]; + +template +struct is_const { + static const bool value = false; +}; + +template +struct is_const { + static const bool value = true; +}; + +int is_const0[is_const::value? -1 : 1]; +int is_const1[is_const::value? 1 : -1]; +int is_const2[is_const::value? 1 : -1]; +int is_const3[is_const::value? 1 : -1]; +int is_const4[is_const::value? 1 : -1]; +int is_const5[is_const::value? -1 : 1]; + +template +struct is_volatile { + static const bool value = false; +}; + +template +struct is_volatile { + static const bool value = true; +}; + +int is_volatile0[is_volatile::value? -1 : 1]; +int is_volatile1[is_volatile::value? 1 : -1]; +int is_volatile2[is_volatile::value? 1 : -1]; +int is_volatile3[is_volatile::value? 1 : -1]; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +typedef int INT; +typedef INT* int_ptr; + +int is_same0[is_same::value? 1 : -1]; +int is_same1[is_same::value? 1 : -1]; +int is_same2[is_same::value? -1 : 1]; +int is_same3[is_same::value? -1 : 1]; + +template +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference { + typedef T type; +}; + +int remove_ref0[is_same::type, int>::value? 1 : -1]; +int remove_ref1[is_same::type, int>::value? 1 : -1]; + +template +struct remove_const { + typedef T type; +}; + +template +struct remove_const { + typedef T type; +}; + +int remove_const0[is_same::type, int>::value? 1 : -1]; +int remove_const1[is_same::type, int[3]>::value? 1 : -1]; + +template +struct is_incomplete_array { + static const bool value = false; +}; + +template +struct is_incomplete_array { + static const bool value = true; +}; + +int incomplete_array0[is_incomplete_array::value ? -1 : 1]; +int incomplete_array1[is_incomplete_array::value ? -1 : 1]; +int incomplete_array2[is_incomplete_array::value ? 1 : -1]; +int incomplete_array3[is_incomplete_array::value ? 1 : -1]; + +template +struct is_array_with_4_elements { + static const bool value = false; +}; + +template +struct is_array_with_4_elements { + static const bool value = true; +}; + +int array_with_4_elements0[is_array_with_4_elements::value ? -1 : 1]; +int array_with_4_elements1[is_array_with_4_elements::value ? -1 : 1]; +int array_with_4_elements2[is_array_with_4_elements::value ? 1 : -1]; +int array_with_4_elements3[is_array_with_4_elements::value ? 1 : -1]; + +template +struct get_array_size; + +template +struct get_array_size { + static const unsigned value = N; +}; + +int array_size0[get_array_size::value == 12? 1 : -1]; + +template +struct remove_extent { + typedef T type; +}; + +template +struct remove_extent { + typedef T type; +}; + +template +struct remove_extent { + typedef T type; +}; + +int remove_extent0[is_same::type, int[5]>::value? 1 : -1]; +int remove_extent1[is_same::type, const int[5]>::value? 1 : -1]; + +template +struct is_unary_function { + static const bool value = false; +}; + +template +struct is_unary_function { + static const bool value = true; +}; + +int is_unary_function0[is_unary_function::value ? -1 : 1]; +int is_unary_function1[is_unary_function::value ? -1 : 1]; +int is_unary_function2[is_unary_function::value ? -1 : 1]; +int is_unary_function3[is_unary_function::value ? 1 : -1]; +int is_unary_function4[is_unary_function::value ? 1 : -1]; + +template +struct is_unary_function_with_same_return_type_as_argument_type { + static const bool value = false; +}; + +template +struct is_unary_function_with_same_return_type_as_argument_type { + static const bool value = true; +}; + +int is_unary_function5[is_unary_function_with_same_return_type_as_argument_type::value ? -1 : 1]; +int is_unary_function6[is_unary_function_with_same_return_type_as_argument_type::value ? -1 : 1]; +int is_unary_function7[is_unary_function_with_same_return_type_as_argument_type::value ? -1 : 1]; +int is_unary_function8[is_unary_function_with_same_return_type_as_argument_type::value ? -1 : 1]; +int is_unary_function9[is_unary_function_with_same_return_type_as_argument_type::value ? 1 : -1]; +int is_unary_function10[is_unary_function_with_same_return_type_as_argument_type::value ? -1 : 1]; +int is_unary_function11[is_unary_function_with_same_return_type_as_argument_type::value ? -1 : 1]; + +template +struct is_binary_function { + static const bool value = false; +}; + +template +struct is_binary_function { + static const bool value = true; +}; + +int is_binary_function0[is_binary_function::value? 1 : -1]; + +template +struct is_member_pointer { + static const bool value = false; +}; + +template +struct is_member_pointer { + static const bool value = true; +}; + +struct X { }; + +int is_member_pointer0[is_member_pointer::value? 1 : -1]; +int is_member_pointer1[is_member_pointer::value? 1 : -1]; +int is_member_pointer2[is_member_pointer::value? 1 : -1]; +int is_member_pointer3[is_member_pointer::value? 1 : -1]; +int is_member_pointer4[is_member_pointer::value? -1 : 1]; +int is_member_pointer5[is_member_pointer::value? -1 : 1]; + +template +struct is_member_function_pointer { + static const bool value = false; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +template +struct is_member_function_pointer { + static const bool value = true; +}; + +int is_member_function_pointer0[ + is_member_function_pointer::value? -1 : 1]; +int is_member_function_pointer1[ + is_member_function_pointer::value? 1 : -1]; +int is_member_function_pointer2[ + is_member_function_pointer::value? 1 : -1]; +int is_member_function_pointer3[ + is_member_function_pointer::value? 1 : -1]; +int is_member_function_pointer4[ + is_member_function_pointer::value? 1 : -1]; + +// Test substitution of non-dependent arguments back into the template +// argument list of the class template partial specialization. +template +struct is_nested_value_type_identity { + static const bool value = false; +}; + +template +struct is_nested_value_type_identity { + static const bool value = true; +}; + +template +struct HasValueType { + typedef T value_type; +}; + +struct HasIdentityValueType { + typedef HasIdentityValueType value_type; +}; + +struct NoValueType { }; + +int is_nested_value_type_identity0[ + is_nested_value_type_identity >::value? -1 : 1]; +int is_nested_value_type_identity1[ + is_nested_value_type_identity::value? 1 : -1]; +int is_nested_value_type_identity2[ + is_nested_value_type_identity::value? -1 : 1]; + + +// C++ [temp.class.spec]p4: +template class A { }; //#1 +template class A { }; //#2 +template class A { }; //#3 +template class A { }; //#4 +template class A { }; //#5 + +// Redefinition of class template partial specializations +template class A0; + +template class A0 { }; // expected-note{{here}} +template class A0; +template class A0 { }; // expected-error{{redef}} + +namespace PR6025 { + template< int N > struct A; + + namespace N + { + template< typename F > + struct B; + } + + template< typename Protect, typename Second > + struct C; + + template + struct C< T, A< N::B::value > > + { + }; +} + +namespace PR6181 { + template + class a; + + class s; + + template + class a // expected-error{{partial specialization of 'a' does not use any of its template parameters}} + { + }; + +} -- cgit v1.2.3