diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-05 02:31:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-05 02:31:32 +0000 |
commit | ec7176e2235ae05e088dd3879a3b41104855388b (patch) | |
tree | 621ec244cc47df73e17c84a86839fd56552065a5 | |
parent | 4a23563c580b815f296ed50baf8234abd8b88607 (diff) | |
download | bcm5719-llvm-ec7176e2235ae05e088dd3879a3b41104855388b.tar.gz bcm5719-llvm-ec7176e2235ae05e088dd3879a3b41104855388b.zip |
Fix assertion failure on deduction failure due to too short template argument list.
We were previously incorrectly using TDK_TooFewArguments to report a template
argument list that's too short, but it actually means that the number of
arguments in a top-level function call was insufficient. When diagnosing the
problem, SemaOverload would (rightly) assert that the failure kind didn't make
any sense.
llvm-svn: 291064
-rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 5 | ||||
-rw-r--r-- | clang/test/SemaTemplate/deduction.cpp | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index c16b28bcf13..893c813485b 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1899,8 +1899,9 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, // Check whether we have enough arguments. if (!hasTemplateArgumentForDeduction(Args, ArgIdx)) - return NumberOfArgumentsMustMatch ? Sema::TDK_TooFewArguments - : Sema::TDK_Success; + return NumberOfArgumentsMustMatch + ? Sema::TDK_MiscellaneousDeductionFailure + : Sema::TDK_Success; // C++1z [temp.deduct.type]p9: // During partial ordering, if Ai was originally a pack expansion [and] diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp index 5695cab9a27..f98fd9bea0c 100644 --- a/clang/test/SemaTemplate/deduction.cpp +++ b/clang/test/SemaTemplate/deduction.cpp @@ -407,3 +407,10 @@ namespace overload_vs_pack { void test() { j(x, f, x); } } } + +namespace b29946541 { + template<typename> class A {}; + template<typename T, typename U, template<typename, typename> class C> + void f(C<T, U>); // expected-note {{failed template argument deduction}} + void g(A<int> a) { f(a); } // expected-error {{no match}} +} |