diff options
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp | 26 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/deduction.cpp | 13 |
2 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp index 1205fd1cf3d..4afbd2d7c16 100644 --- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -176,3 +176,29 @@ namespace default_args_from_ctor { template <class A> struct T { template<typename B> T(A = 0, B = 0) {} }; T t(0, 0); } + +namespace transform_params { + template<typename T, T N, template<T (*v)[N]> typename U, T (*X)[N]> + struct A { // expected-note 2{{candidate}} + template<typename V, V M, V (*Y)[M], template<V (*v)[M]> typename W> + A(U<X>, W<Y>); // expected-note {{[with V = int, M = 12, Y = &transform_params::n]}} + + static constexpr T v = N; + }; + + int n[12]; + template<int (*)[12]> struct Q {}; + Q<&n> qn; + // FIXME: The class template argument deduction result here is correct, but + // we incorrectly fail to deduce arguments for the constructor! + A a(qn, qn); // expected-error {{no matching constructor for initialization of 'transform_params::A<int, 12, Q, &transform_params::n>'}} + static_assert(a.v == 12); + + // FIXME: This causes a crash right now (not class template deduction related). +#if 0 + template<typename ...T> struct B { + template<T ...V> B(T (&...p)[V]); + }; + B b({1, 2, 3}, {"foo", "bar"}, {'x', 'y', 'z', 'w'}); +#endif +} diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp index 16e01a93463..a1180f09887 100644 --- a/clang/test/SemaTemplate/deduction.cpp +++ b/clang/test/SemaTemplate/deduction.cpp @@ -481,3 +481,16 @@ namespace check_extended_pack { int n; void h() { g<0>(Y<0, &n>()); } // expected-error {{no matching function}} } + +namespace dependent_template_template_param_non_type_param_type { + template<int N> struct A { // expected-note 2{{candidate}} + template<typename V = int, V M = 12, V (*Y)[M], template<V (*v)[M]> class W> + A(W<Y>); // expected-note {{[with V = int, M = 12, Y = &dependent_template_template_param_non_type_param_type::n]}} + }; + + int n[12]; + template<int (*)[12]> struct Q {}; + Q<&n> qn; + // FIXME: This should be accepted, but we somehow fail to deduce W. + A<0> a(qn); // expected-error {{no matching constructor for initialization}} +} |

