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). --- .../temp.variadic/multi-level-substitution.cpp | 251 +++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp (limited to 'clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp') diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp new file mode 100644 index 0000000..21aa24f --- /dev/null +++ b/clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp @@ -0,0 +1,251 @@ +// RUN: %clang_cc1 -std=c++11 -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'}} +} + +namespace ExpandingFunctionParameters { + template + struct X0 { + typedef int type; + }; + + template + struct X1 { + template + typename X0::type f(U...); + }; + + void test() { + X1 x1; + x1.f(17, 3.14159); + } +} + +namespace PR10230 { + template + struct s + { + template + auto f() -> int(&)[sizeof...(Args)]; + }; + + void main() + { + int (&ir1)[1] = s().f(); + int (&ir3)[3] = s().f(); + } +} -- cgit v1.2.3