diff options
Diffstat (limited to 'clang/test/SemaTemplate/class-template-spec.cpp')
-rw-r--r-- | clang/test/SemaTemplate/class-template-spec.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/clang/test/SemaTemplate/class-template-spec.cpp b/clang/test/SemaTemplate/class-template-spec.cpp index 86cace19dbf..cee84a750b6 100644 --- a/clang/test/SemaTemplate/class-template-spec.cpp +++ b/clang/test/SemaTemplate/class-template-spec.cpp @@ -167,10 +167,16 @@ namespace PR16519 { // expected-warning@-2 {{variadic templates are a C++11 extension}} #endif - template<typename T, T ...N, T ...Extra> struct __make_integer_sequence_impl<integer_sequence<T, N...>, Extra...> { + // Note that the following seemingly-equivalent template parameter list is + // not OK; it would result in a partial specialization that is not more + // specialized than the primary template. (See NTTPTypeVsPartialOrder below.) + // + // template<typename T, T ...N, T ...Extra> + template<typename T, T ...N, typename integer_sequence<T, N...>::value_type ...Extra> #if __cplusplus <= 199711L - // expected-warning@-2 2 {{variadic templates are a C++11 extension}} + // expected-warning@-2 2{{variadic templates are a C++11 extension}} #endif + struct __make_integer_sequence_impl<integer_sequence<T, N...>, Extra...> { typedef integer_sequence<T, N..., sizeof...(N) + N..., Extra...> type; }; @@ -193,6 +199,25 @@ namespace PR16519 { #endif } +namespace NTTPTypeVsPartialOrder { + struct X { typedef int value_type; }; + template<typename T> struct Y { typedef T value_type; }; + + template<typename T, typename T::value_type N> struct A; // expected-note {{template}} + template<int N> struct A<X, N> {}; + template<typename T, T N> struct A<Y<T>, N> {}; // expected-error {{not more specialized}} expected-note {{'T' vs 'typename Y<type-parameter-0-0>::value_type'}} + A<X, 0> ax; + A<Y<int>, 0> ay; + + + template<int, typename T, typename T::value_type> struct B; // expected-note {{template}} + template<typename T, typename T::value_type N> struct B<0, T, N>; // expected-note {{matches}} + template<int N> struct B<0, X, N> {}; + template<typename T, T N> struct B<0, Y<T>, N> {}; // expected-error {{not more specialized}} expected-note {{'T' vs 'typename Y<type-parameter-0-0>::value_type'}} expected-note {{matches}} + B<0, X, 0> bx; + B<0, Y<int>, 0> by; // expected-error {{ambiguous}} +} + namespace DefaultArgVsPartialSpec { // Check that the diagnostic points at the partial specialization, not just at // the default argument. |