]> granicus.if.org Git - clang/commitdiff
Fix assertion failure on deduction failure due to too short template argument list.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 5 Jan 2017 02:31:32 +0000 (02:31 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 5 Jan 2017 02:31:32 +0000 (02:31 +0000)
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

lib/Sema/SemaTemplateDeduction.cpp
test/SemaTemplate/deduction.cpp

index c16b28bcf13902330c8917ffd375d78a8c94fe9c..893c813485b7bcd57427f5e3ef40172493c0d824 100644 (file)
@@ -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]
index 5695cab9a27e5b991366f8e74abeb23d9a31d5ff..f98fd9bea0c7c7e0a51069dc0587f0df38ddc137 100644 (file)
@@ -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}}
+}