summaryrefslogtreecommitdiffstats
path: root/test/SemaTemplate/alias-templates.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaTemplate/alias-templates.cpp')
-rw-r--r--test/SemaTemplate/alias-templates.cpp76
1 files changed, 71 insertions, 5 deletions
diff --git a/test/SemaTemplate/alias-templates.cpp b/test/SemaTemplate/alias-templates.cpp
index 75615ee..20ba6e0 100644
--- a/test/SemaTemplate/alias-templates.cpp
+++ b/test/SemaTemplate/alias-templates.cpp
@@ -73,19 +73,38 @@ namespace PR11848 {
template<typename T> using U = int;
template<typename T, typename ...Ts>
- void f(U<T> i, U<Ts> ...is) { // expected-error {{type 'U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}}
- return i + f<Ts...>(is...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
+ void f1(U<T> i, U<Ts> ...is) { // expected-note 2{{couldn't infer template argument 'T'}}
+ return i + f1<Ts...>(is...);
+ }
+
+ // FIXME: This note is technically correct, but could be better. We
+ // should really say that we couldn't infer template argument 'Ts'.
+ template<typename ...Ts>
+ void f2(U<Ts> ...is) { } // expected-note {{requires 0 arguments, but 1 was provided}}
+
+ template<typename...> struct type_tuple {};
+ template<typename ...Ts>
+ void f3(type_tuple<Ts...>, U<Ts> ...is) {} // expected-note {{requires 4 arguments, but 3 were provided}}
+
+ void g() {
+ f1(U<void>()); // expected-error {{no match}}
+ f1(1, 2, 3, 4, 5); // expected-error {{no match}}
+ f2(); // ok
+ f2(1); // expected-error {{no match}}
+ f3(type_tuple<>());
+ f3(type_tuple<void, void, void>(), 1, 2); // expected-error {{no match}}
+ f3(type_tuple<void, void, void>(), 1, 2, 3);
}
template<typename ...Ts>
struct S {
- S(U<Ts>...ts); // expected-error {{does not contain any unexpanded parameter packs}}
+ S(U<Ts>...ts);
};
template<typename T>
struct Hidden1 {
template<typename ...Ts>
- Hidden1(typename T::template U<Ts> ...ts); // expected-error{{type 'typename Hide::U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}}
+ Hidden1(typename T::template U<Ts> ...ts);
};
template<typename T, typename ...Ts>
@@ -97,6 +116,53 @@ namespace PR11848 {
template<typename T> using U = int;
};
- Hidden1<Hide> h1; // expected-note{{in instantiation of template class 'PR11848::Hidden1<PR11848::Hide>' requested here}}
+ Hidden1<Hide> h1;
Hidden2<Hide, double, char> h2(1, 2);
}
+
+namespace Core22036 {
+ struct X {};
+ void h(...);
+ template<typename T> using Y = X;
+ template<typename T, typename ...Ts> struct S {
+ // An expression can contain an unexpanded pack without being type or
+ // value dependent. This is true even if the expression's type is a pack
+ // expansion type.
+ void f1(Y<T> a) { h(g(a)); } // expected-error {{undeclared identifier 'g'}}
+ void f2(Y<Ts>...as) { h(g(as)...); } // expected-error {{undeclared identifier 'g'}}
+ void f3(Y<Ts>...as) { g(as...); } // ok
+ void f4(Ts ...ts) { h(g(sizeof(ts))...); } // expected-error {{undeclared identifier 'g'}}
+ // FIXME: We can reject this, since it has no valid instantiations because
+ // 'g' never has any associated namespaces.
+ void f5(Ts ...ts) { g(sizeof(ts)...); } // ok
+ };
+}
+
+namespace PR13243 {
+ template<typename A> struct X {};
+ template<int I> struct C {};
+ template<int I> using Ci = C<I>;
+
+ template<typename A, int I> void f(X<A>, Ci<I>) {}
+ template void f(X<int>, C<0>);
+}
+
+namespace PR13136 {
+ template <typename T, T... Numbers>
+ struct NumberTuple { };
+
+ template <unsigned int... Numbers>
+ using MyNumberTuple = NumberTuple<unsigned int, Numbers...>;
+
+ template <typename U, unsigned int... Numbers>
+ void foo(U&&, MyNumberTuple<Numbers...>);
+
+ template <typename U, unsigned int... Numbers>
+ void bar(U&&, NumberTuple<unsigned int, Numbers...>);
+
+ int main() {
+ foo(1, NumberTuple<unsigned int, 0, 1>());
+ bar(1, NumberTuple<unsigned int, 0, 1>());
+ return 0;
+ }
+}
OpenPOWER on IntegriCloud