summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-11 01:52:23 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-11 01:52:23 +0000
commit0dd423ef334c9d7c2a69ceace7e8329e1f2f4932 (patch)
tree2caa3e336a07ed093fa1239d1c25b8fb08909a51 /clang/lib/AST/Decl.cpp
parent0d771edeee525b2e5438e38c812af0c871133d0b (diff)
downloadbcm5719-llvm-0dd423ef334c9d7c2a69ceace7e8329e1f2f4932.tar.gz
bcm5719-llvm-0dd423ef334c9d7c2a69ceace7e8329e1f2f4932.zip
Implement the last bullet of [temp.deduct.type]p5 and part of the last
sentence of [temp.deduct.call]p1, both of which concern the non-deducibility of parameter packs not at the end of a parameter-type-list. The latter isn't fully implemented yet; see the new FIXME. llvm-svn: 123210
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 24fc45f4be1..786f28a60da 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1444,6 +1444,9 @@ void FunctionDecl::setParams(ASTContext &C,
/// function parameters, if some of the parameters have default
/// arguments (in C++) or the last parameter is a parameter pack.
unsigned FunctionDecl::getMinRequiredArguments() const {
+ if (!getASTContext().getLangOptions().CPlusPlus)
+ return getNumParams();
+
unsigned NumRequiredArgs = getNumParams();
// If the last parameter is a parameter pack, we don't need an argument for
@@ -1458,6 +1461,16 @@ unsigned FunctionDecl::getMinRequiredArguments() const {
getParamDecl(NumRequiredArgs-1)->hasDefaultArg())
--NumRequiredArgs;
+ // We might have parameter packs before the end. These can't be deduced,
+ // but they can still handle multiple arguments.
+ unsigned ArgIdx = NumRequiredArgs;
+ while (ArgIdx > 0) {
+ if (getParamDecl(ArgIdx - 1)->isParameterPack())
+ NumRequiredArgs = ArgIdx;
+
+ --ArgIdx;
+ }
+
return NumRequiredArgs;
}
OpenPOWER on IntegriCloud