diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-17 20:42:37 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-17 20:42:37 +0000 |
| commit | d663fdd2165d39862f7d466412b0321a776070f2 (patch) | |
| tree | 09244b8ca3bb048fdbfd2ffd2aa96b30a8d9c215 /clang/test | |
| parent | 2055538edbc270c2e6dce3c84593482fe34c0df3 (diff) | |
| download | bcm5719-llvm-d663fdd2165d39862f7d466412b0321a776070f2.tar.gz bcm5719-llvm-d663fdd2165d39862f7d466412b0321a776070f2.zip | |
[c++1z] Fixes for generalized non-type template argument support: check for
exact type match for deduced template arguments, and be sure to produce correct
canonical TemplateArgument representations to enable correct redeclaration
matching.
llvm-svn: 224456
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp index ff973f0b2a4..5000927d894 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp @@ -109,4 +109,42 @@ namespace PtrMem { static_assert(!is_same<Ae, Aedb>, ""); // expected-error {{undeclared}} expected-error {{must be a type}} static_assert(!is_same<Aecb, Aedb>, ""); // expected-error 2{{undeclared}} expected-error {{must be a type}} static_assert(is_same<Aecb, A<int E::*, (int E::*)(int C::*)&B::b>, ""); // expected-error {{undeclared}} expected-error {{not supported}} + + using An = A<int E::*, nullptr>; + using A0 = A<int E::*, (int E::*)0>; + static_assert(is_same<An, A0>); +} + +namespace DeduceDifferentType { + template<int N> struct A {}; + template<long N> int a(A<N>); // expected-note {{does not have the same type}} + int a_imp = a(A<3>()); // expected-error {{no matching function}} + int a_exp = a<3>(A<3>()); + + template<decltype(nullptr)> struct B {}; + template<int *P> int b(B<P>); // expected-note {{could not match}} expected-note {{not implicitly convertible}} + int b_imp = b(B<nullptr>()); // expected-error {{no matching function}} + int b_exp = b<nullptr>(B<nullptr>()); // expected-error {{no matching function}} + + struct X { constexpr operator int() { return 0; } } x; + template<X &> struct C {}; + template<int N> int c(C<N>); // expected-note {{does not have the same type}} expected-note {{not implicitly convertible}} + int c_imp = c(C<x>()); // expected-error {{no matching function}} + int c_exp = c<x>(C<x>()); // expected-error {{no matching function}} + + struct Z; + struct Y { constexpr operator Z&(); } y; + struct Z { constexpr operator Y&() { return y; } } z; + constexpr Y::operator Z&() { return z; } + template<Y &> struct D {}; + template<Z &z> int d(D<z>); // expected-note {{does not have the same type}} + int d_imp = d(D<y>()); // expected-error {{no matching function}} + int d_exp = d<y>(D<y>()); +} + +namespace DeclMatch { + template<typename T, T> int f(); + template<typename T> class X { friend int f<T, 0>(); static int n; }; + template<typename T, T> int f() { return X<T>::n; } + int k = f<int, 0>(); // ok, friend } |

