Cope with explicitly-specified function template arguments when there
are fewer template arguments than there are template parameters for
that function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74578 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 810de04..ae0e704 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -934,21 +934,24 @@
// there are corresponding template-parameters.
TemplateArgumentListBuilder Builder(TemplateParams,
NumExplicitTemplateArgs);
+
+ // Enter a new template instantiation context where we check the
+ // explicitly-specified template arguments against this function template,
+ // and then substitute them into the function parameter types.
+ InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
+ FunctionTemplate, Deduced.data(), Deduced.size());
+ if (Inst)
+ return TDK_InstantiationDepth;
+
if (CheckTemplateArgumentList(FunctionTemplate,
SourceLocation(), SourceLocation(),
ExplicitTemplateArgs,
NumExplicitTemplateArgs,
SourceLocation(),
+ true,
Builder) || Trap.hasErrorOccurred())
return TDK_InvalidExplicitArguments;
- // Enter a new template instantiation context for the substitution of the
- // explicitly-specified template arguments into the
- InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
- FunctionTemplate, Deduced.data(), Deduced.size());
- if (Inst)
- return TDK_InstantiationDepth;
-
// Form the template argument list from the explicitly-specified
// template arguments.
TemplateArgumentList *ExplicitArgumentList