From: Richard Smith Date: Thu, 5 Jan 2017 02:31:32 +0000 (+0000) Subject: Fix assertion failure on deduction failure due to too short template argument list. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf2ed0b529c8fb34b2e098c30adce12a577d05f3;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291064 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index c16b28bcf1..893c813485 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/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/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index 5695cab9a2..f98fd9bea0 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -407,3 +407,10 @@ namespace overload_vs_pack { void test() { j(x, f, x); } } } + +namespace b29946541 { + template class A {}; + template class C> + void f(C); // expected-note {{failed template argument deduction}} + void g(A a) { f(a); } // expected-error {{no match}} +}