diff options
Diffstat (limited to 'test/CXX/temp/temp.decls/temp.variadic')
-rw-r--r-- | test/CXX/temp/temp.decls/temp.variadic/p2.cpp | 2 | ||||
-rw-r--r-- | test/CXX/temp/temp.decls/temp.variadic/p5.cpp | 12 | ||||
-rw-r--r-- | test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp | 203 |
3 files changed, 216 insertions, 1 deletions
diff --git a/test/CXX/temp/temp.decls/temp.variadic/p2.cpp b/test/CXX/temp/temp.decls/temp.variadic/p2.cpp index ce19582..e7a6236 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p2.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p2.cpp @@ -12,7 +12,7 @@ void test() { template<typename Head, typename ...Tail> void recurse_until_fail(const Head &, const Tail &...tail) { // expected-note{{candidate function template not viable: requires at least 1 argument, but 0 were provided}} recurse_until_fail(tail...); // expected-error{{no matching function for call to 'recurse_until_fail'}} \ - // expected-note{{in instantiation of function template specialization 'recurse_until_fail<char [7], >' requested here}} \ + // expected-note{{in instantiation of function template specialization 'recurse_until_fail<char [7]>' requested here}} \ // expected-note{{in instantiation of function template specialization 'recurse_until_fail<double, char [7]>' requested here}} } diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp index 9453798..3681d77 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -165,6 +165,7 @@ template<typename T, typename... Types> struct alignas(Types) TestUnexpandedDecls : T{ // expected-error{{expression contains unexpanded parameter pack 'Types'}} void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} void member_function () throw(Types); // expected-error{{exception type contains unexpanded parameter pack 'Types'}} + void member_function2() noexcept(Types()); // expected-error{{expression contains unexpanded parameter pack 'Types'}} operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} Types data_member; // expected-error{{data member type contains unexpanded parameter pack 'Types'}} static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} @@ -410,3 +411,14 @@ namespace WorkingPaperExample { f(h(args ...) + args ...); } } + +namespace PR16303 { + template<int> struct A { A(int); }; + template<int...N> struct B { + template<int...M> struct C : A<N>... { + C() : A<N>(M)... {} // expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (2 vs. 3)}} expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (4 vs. 3)}} + }; + }; + B<1,2>::C<4,5,6> c1; // expected-note{{in instantiation of}} + B<1,2,3,4>::C<4,5,6> c2; // expected-note{{in instantiation of}} +} diff --git a/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp b/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp new file mode 100644 index 0000000..4960a2b --- /dev/null +++ b/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp @@ -0,0 +1,203 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// expected-no-diagnostics + +namespace pr12262 { + +template<typename T, typename... Ts> +void abc1(int (*xxx)[sizeof ... (Ts) + 1]); + +void qq1 () { + abc1<int>(0); + abc1<int,double>(0); +} + + +template <unsigned N> class array {}; + + +template<typename T, typename... Types> +array<sizeof...(Types)> make_array1(Types&&... args); + +void qq2 () { + array<1> arr = make_array1<int>(1); + array<3> arr2 = make_array1<int>(1,array<5>(),0.1); +} + + +template<typename T, typename... Types> +int make_array(array<sizeof...(Types)>&, Types... args); + +void qq3 () { + array<1> a1; + int aa1 = make_array<int>(a1,1); + array<2> a2; + int aa2 = make_array<int>(a2, 0L, "abc"); +} + + +template<typename ... Ts> +struct AAA { + template<typename T, typename... Types> + static array<sizeof...(Types)> make_array(Types ... args); +}; + +void qq4 () { + array<2> arr2 = AAA<int, int>::make_array<int>(1,2); +} + +} + + +namespace pr12439 { + +template<class... Members> +struct X { + template<int Idx> + using get_t = decltype(sizeof...(Members)); + + template<int i> + get_t<i> get(); +}; + +template<class... Members> +template<int i> +X<Members...>::get_t<i> X<Members...>::get() +{ + return 0; +} + +} + + +namespace pr13272 { + +template<bool B, class T = void> +struct enable_if { }; + +template<class T> struct enable_if<true, T> { + typedef T type; +}; + +class Exception {}; + +template<class Ex, typename... Args> +void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) { + return; +} + +void test() { + cxx_throw<Exception>("Youpi",1); +} + +} + + +namespace pr13817 { + +template <unsigned> +struct zod; + +template <> +struct zod<1> {}; + +template <typename T, typename ... Ts> +zod<sizeof...(Ts)> make_zod(Ts ...) { + return zod<sizeof...(Ts)>(); +} + +int main(int argc, char *argv[]) +{ + make_zod<int>(1); + return 0; +} + +} + + +namespace pr14273 { + +template<typename T, int i> +struct myType +{ }; + +template<typename T, typename... Args> +struct Counter +{ + static const int count = 1 + Counter<Args...>::count; +}; + +template<typename T> +struct Counter<T> +{ + static const int count = 1; +}; + +template<typename Arg, typename... Args> +myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args) +{ + return 0; +} + +void func(void) +{ + make_array_with_type<char>(1,2,3); +} + +} + + +namespace pr15112 +{ + template<bool, typename _Tp = void> + struct enable_if + { }; + template<typename _Tp> + struct enable_if<true,_Tp> + { typedef _Tp type; }; + + typedef __typeof__(sizeof(int)) size_t; + + template <size_t n, typename T, typename... Args> + struct is_array_of { static const bool value = true; }; + + struct cpu { using value_type = void; }; + + template <size_t Order, typename T> + struct coords_alias { typedef T type; }; + + template <size_t Order, typename MemoryTag> + using coords = typename coords_alias<Order, MemoryTag>::type; + + template <typename MemTag, typename... Args> + typename enable_if<is_array_of<sizeof...(Args), size_t, Args...>::value, + coords<sizeof...(Args), MemTag>>::type + mkcoords(Args... args); + + auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul); +} + + +namespace pr12699 { + +template<bool B> +struct bool_constant +{ + static const bool value = B; +}; + +template<typename... A> +struct F +{ + template<typename... B> + using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>; + + template<typename... B, typename = SameSize<B...>> + F(B...) { } +}; + +void func() +{ + F<int> f1(3); +} + +} |