From 7825bf3a12007492378be0052e583bb4bef3f548 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 6 Jan 2011 22:09:01 +0000 Subject: Implement template argument deduction from a call to a function template whose last parameter is a parameter pack. This allows us to form a call to, e.g., template void f(std::pair ...pairs); given zero or more instances of "pair". llvm-svn: 122973 --- clang/lib/AST/Decl.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'clang/lib/AST/Decl.cpp') diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index c51d2cdc37c..a76a5748b46 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1442,11 +1442,20 @@ void FunctionDecl::setParams(ASTContext &C, /// getMinRequiredArguments - Returns the minimum number of arguments /// needed to call this function. This may be fewer than the number of /// function parameters, if some of the parameters have default -/// arguments (in C++). +/// arguments (in C++) or the last parameter is a parameter pack. unsigned FunctionDecl::getMinRequiredArguments() const { - unsigned NumRequiredArgs = getNumParams(); - while (NumRequiredArgs > 0 - && getParamDecl(NumRequiredArgs-1)->hasDefaultArg()) + unsigned NumRequiredArgs = getNumParams(); + + // If the last parameter is a parameter pack, we don't need an argument for + // it. + if (NumRequiredArgs > 0 && + getParamDecl(NumRequiredArgs - 1)->isParameterPack()) + --NumRequiredArgs; + + // If this parameter has a default argument, we don't need an argument for + // it. + while (NumRequiredArgs > 0 && + getParamDecl(NumRequiredArgs-1)->hasDefaultArg()) --NumRequiredArgs; return NumRequiredArgs; -- cgit v1.2.3