diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-21 06:30:38 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-21 06:30:38 +0000 |
| commit | b4f9625a7bd5601534952b478040e6836e37eb47 (patch) | |
| tree | 4cfa08c4839e2e7be37102ccd5797a78beb1f18e /clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp | |
| parent | 16d9730b8673741e4b2b18caa087f71c2318be98 (diff) | |
| download | bcm5719-llvm-b4f9625a7bd5601534952b478040e6836e37eb47.tar.gz bcm5719-llvm-b4f9625a7bd5601534952b478040e6836e37eb47.zip | |
PR32010: Fix template argument depth mixup when forming implicit constructor
template deduction guides for class template argument deduction.
Ensure that we have a local instantiation scope for tracking the instantiated
parameters. Additionally, unusually, we're substituting at depth 1 and leaving
depth 0 alone; make sure that we don't reduce template parameter depth by 2 for
inner parameters in the process. (This is probably also broken for alias
templates in the case where they're expanded within a dependent context, but
this patch doesn't fix that.)
llvm-svn: 295696
Diffstat (limited to 'clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp')
| -rw-r--r-- | clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp | 26 |
1 files changed, 26 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 +} |

