summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/drs/dr14xx.cpp28
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp4
-rw-r--r--clang/test/SemaTemplate/class-template-spec.cpp29
-rw-r--r--clang/test/SemaTemplate/temp_arg_nontype.cpp20
4 files changed, 69 insertions, 12 deletions
diff --git a/clang/test/CXX/drs/dr14xx.cpp b/clang/test/CXX/drs/dr14xx.cpp
index 9491f7da147..9e724d91834 100644
--- a/clang/test/CXX/drs/dr14xx.cpp
+++ b/clang/test/CXX/drs/dr14xx.cpp
@@ -342,4 +342,32 @@ namespace dr1490 { // dr1490: 3.7 c++11
char s[4]{"abc"}; // Ok
std::initializer_list<char>{"abc"}; // expected-error {{expected unqualified-id}}}
} // dr190
+
+namespace dr1495 { // dr1495: 4.0
+ // Deduction succeeds in both directions.
+ template<typename T, typename U> struct A {}; // expected-note {{template is declared here}}
+ template<typename T, typename U> struct A<U, T> {}; // expected-error {{class template partial specialization is not more specialized}}
+
+ // Primary template is more specialized.
+ template<typename, typename...> struct B {}; // expected-note {{template is declared here}}
+ template<typename ...Ts> struct B<Ts...> {}; // expected-error {{not more specialized}}
+
+ // Deduction fails in both directions.
+ template<int, typename, typename ...> struct C {}; // expected-note {{template is declared here}}
+ template<typename ...Ts> struct C<0, Ts...> {}; // expected-error {{not more specialized}}
+
+#if __cplusplus >= 201402L
+ // Deduction succeeds in both directions.
+ template<typename T, typename U> int a; // expected-note {{template is declared here}}
+ template<typename T, typename U> int a<U, T>; // expected-error {{variable template partial specialization is not more specialized}}
+
+ // Primary template is more specialized.
+ template<typename, typename...> int b; // expected-note {{template is declared here}}
+ template<typename ...Ts> int b<Ts...>; // expected-error {{not more specialized}}
+
+ // Deduction fails in both directions.
+ template<int, typename, typename ...> int c; // expected-note {{template is declared here}}
+ template<typename ...Ts> int c<0, Ts...>; // expected-error {{not more specialized}}
+#endif
+}
#endif
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
index a466be0a61d..a990c82564a 100644
--- a/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
@@ -108,10 +108,10 @@ namespace PR9021b {
namespace PartialSpecialization {
template<typename T, typename U, typename V = U>
- struct X0; // expected-note{{template is declared here}}
+ struct X0; // expected-note 2{{template is declared here}}
template<typename ...Ts>
- struct X0<Ts...> {
+ struct X0<Ts...> { // expected-error {{class template partial specialization is not more specialized than the primary template}}
};
X0<int> x0i; // expected-error{{too few template arguments for class template 'X0'}}
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.
diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp
index e99c56ba1f5..dc67ecac1d4 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -367,11 +367,11 @@ namespace PR17696 {
namespace partial_order_different_types {
// These are unordered because the type of the final argument doesn't match.
- // FIXME: The second partial specialization should actually be rejected
- // because it's not more specialized than the primary template.
- template<int, int, typename T, typename, T> struct A;
+ template<int, int, typename T, typename, T> struct A; // expected-note {{here}}
template<int N, typename T, typename U, T V> struct A<0, N, T, U, V> {}; // expected-note {{matches}}
template<typename T, typename U, U V> struct A<0, 0, T, U, V> {}; // expected-note {{matches}}
+ // expected-error@-1 {{not more specialized than the primary}}
+ // expected-note@-2 {{deduced non-type template argument does not have the same type as the corresponding template parameter ('U' vs 'type-parameter-0-0')}}
A<0, 0, int, int, 0> a; // expected-error {{ambiguous partial specializations}}
}
@@ -389,18 +389,22 @@ namespace partial_order_references {
int N;
A<0, 0, N> a;
- // FIXME: These should all be rejected as they are not more specialized than
- // the primary template (they can never be used due to the type mismatch).
- template<int, int &R> struct B; // expected-note {{template}}
+ template<int, int &R> struct B; // expected-note 2{{template}}
template<const int &R> struct B<0, R> {};
+ // expected-error@-1 {{not more specialized than the primary}}
+ // expected-note@-2 {{'const int' vs 'int &'}}
B<0, N> b; // expected-error {{undefined}}
- template<int, const int &R> struct C; // expected-note {{template}}
+ template<int, const int &R> struct C; // expected-note 2{{template}}
template<int &R> struct C<0, R> {};
+ // expected-error@-1 {{not more specialized than the primary}}
+ // expected-note@-2 {{'int' vs 'const int &'}}
C<0, N> c; // expected-error {{undefined}}
- template<int, const int &R> struct D; // expected-note {{template}}
+ template<int, const int &R> struct D; // expected-note 2{{template}}
template<int N> struct D<0, N> {};
+ // expected-error@-1 {{not more specialized than the primary}}
+ // expected-note@-2 {{'int' vs 'const int &'}}
extern const int K = 5;
D<0, K> d; // expected-error {{undefined}}
}
OpenPOWER on IntegriCloud