Author: rsmith Date: Wed Jan 4 20:31:32 2017 New Revision: 291064 URL: http://llvm.org/viewvc/llvm-project?rev=291064&view=rev Log: 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. Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp cfe/trunk/test/SemaTemplate/deduction.cpp Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=291064&r1=291063&r2=291064&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Jan 4 20:31:32 2017 @@ -1899,8 +1899,9 @@ DeduceTemplateArguments(Sema &S, Templat // 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] Modified: cfe/trunk/test/SemaTemplate/deduction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=291064&r1=291063&r2=291064&view=diff ============================================================================== --- cfe/trunk/test/SemaTemplate/deduction.cpp (original) +++ cfe/trunk/test/SemaTemplate/deduction.cpp Wed Jan 4 20:31:32 2017 @@ -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}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits