From 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 20 Feb 2011 13:06:31 +0000 Subject: Vendor import of clang trunk r126079: http://llvm.org/svn/llvm-project/cfe/trunk@126079 --- .../temp.variadic/multi-level-substitution.cpp | 218 +++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp (limited to 'test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp') diff --git a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp new file mode 100644 index 0000000..2df6d33 --- /dev/null +++ b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp @@ -0,0 +1,218 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +template struct value_tuple {}; +template struct tuple { }; +template struct pair { }; + +template struct value_c; + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +template +struct X0 { + template + void f(value_tuple * = 0); +}; + +void test_X0() { + X0().f<1, 2, 3, 4, 5>(); +} + +namespace PacksAtDifferentLevels { + + template + struct X { + template struct Inner { + static const unsigned value = 1; + }; + + template + struct Inner...> > { + static const unsigned value = sizeof...(Types) - sizeof...(YTypes); + }; + }; + + int check0[X::Inner, + pair, + pair> + >::value == 0? 1 : -1]; + + int check1[X::Inner, + pair, + pair> + >::value == 1? 1 : -1]; + + template struct unsigned_tuple { }; + template + struct X1 { + template struct Inner { + static const unsigned value = 0; + }; + + template + struct Inner...>, + unsigned_tuple> { + static const unsigned value = 1; + }; + }; + + int check2[X1::Inner, + pair, + pair>, + unsigned_tuple + >::value == 1? 1 : -1]; + int check3[X1::Inner, + pair, + pair>, + unsigned_tuple + >::value == 0? 1 : -1]; + + template + struct X2 { + template struct Inner { + static const unsigned value = 1; + }; + + template + struct Inner...)> { + static const unsigned value = sizeof...(Types) - sizeof...(YTypes); + }; + }; + + int check4[X2::Inner, + pair, + pair) + >::value == 0? 1 : -1]; + + int check5[X2::Inner, + pair, + pair) + >::value == 1? 1 : -1]; + + template + struct some_function_object { + template + struct result_of; + }; + + template class...> struct metafun_tuple { }; + + template + struct X3 { + template struct Inner { + static const unsigned value = 0; + }; + + template + struct Inner...>, + metafun_tuple::template result_of...> > { + static const unsigned value = 1; + }; + }; + + int check6[X3::Inner, + pair, + pair>, + metafun_tuple< + some_function_object::result_of, + some_function_object::result_of, + some_function_object::result_of> + >::value == 1? 1 : -1]; + int check7[X3::Inner, + pair, + pair>, + metafun_tuple< + some_function_object::result_of, + some_function_object::result_of, + some_function_object::result_of> + >::value == 0? 1 : -1]; + + template struct unsigned_pair { }; + + template + struct X4 { + template struct Inner { + static const unsigned value = 0; + }; + + template + struct Inner...>> { + static const unsigned value = 1; + }; + }; + + int check8[X4<1, 3, 5>::Inner, + unsigned_pair<3, 4>, + unsigned_pair<5, 6>> + >::value == 1? 1 : -1]; + int check9[X4<1, 3>::Inner, + unsigned_pair<3, 4>, + unsigned_pair<5, 6>> + >::value == 0? 1 : -1]; + + template struct add_reference; + template struct add_pointer; + template struct add_const; + + template class ...Templates> + struct X5 { + template struct Inner { + static const unsigned value = 0; + }; + + template + struct Inner...>> { + static const unsigned value = 1; + }; + }; + + int check10[X5 + ::Inner, + add_pointer, + add_const>>::value == 1? 1 : -1]; + int check11[X5 + ::Inner, + add_pointer, + add_const>>::value == 0? 1 : -1]; + +} + +namespace ExpandingNonTypeTemplateParameters { + template + struct tuple_of_values { + template // expected-error{{a non-type template parameter cannot have type 'float'}} \ + // expected-note{{template parameter is declared here}} + struct apply { // expected-note 2{{template is declared here}} + typedef tuple...> type; + }; + }; + + int i; + float f; + int check_tuple_of_values_1[ + is_same::apply + ::type, + tuple, value_c, value_c, + value_c> + >::value? 1 : -1]; + + tuple_of_values tv1; // expected-note{{in instantiation of template class 'ExpandingNonTypeTemplateParameters::tuple_of_values' requested here}} + + tuple_of_values::apply::type tv2; // expected-error{{non-type template parameter of reference type 'float &' cannot bind to template argument of type 'int'}} + + tuple_of_values::apply::type tv3; // expected-error{{too few template arguments for class template 'apply'}} + + tuple_of_values::apply::type tv4; // expected-error{{too many template arguments for class template 'apply'}} +} -- cgit v1.1