aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-04-17 19:00:52 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-04-17 19:00:52 +0000
commit987c03085558277a5fe8cef8e1b628cabcc626dc (patch)
tree2be148645ad961beef8acc0e1bddf29d4228cd3b
parent82b0f86252c050b43f2e5d5425d6e37970aabd7c (diff)
PR15755: don't drop parameter packs when dropping parameters with default
arguments in the formation of a candidate set of inheriting constructors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179708 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp17
-rw-r--r--test/CXX/special/class.inhctor/p1.cpp13
2 files changed, 23 insertions, 7 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index fd3489fd53..94a507449b 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -7827,13 +7827,16 @@ private:
// constructor templates that results from omitting any ellipsis parameter
// specification and successively omitting parameters with a default
// argument from the end of the parameter-type-list
- for (unsigned Params = std::max(minParamsToInherit(Ctor),
- Ctor->getMinRequiredArguments()),
- MaxParams = Ctor->getNumParams();
- Params <= MaxParams; ++Params)
- declareCtor(UsingLoc, Ctor,
- SemaRef.Context.getFunctionType(
- Ctor->getResultType(), ArgTypes.slice(0, Params), EPI));
+ unsigned MinParams = minParamsToInherit(Ctor);
+ unsigned Params = Ctor->getNumParams();
+ if (Params >= MinParams) {
+ do
+ declareCtor(UsingLoc, Ctor,
+ SemaRef.Context.getFunctionType(
+ Ctor->getResultType(), ArgTypes.slice(0, Params), EPI));
+ while (Params > MinParams &&
+ Ctor->getParamDecl(--Params)->hasDefaultArg());
+ }
}
/// Find the using-declaration which specified that we should inherit the
diff --git a/test/CXX/special/class.inhctor/p1.cpp b/test/CXX/special/class.inhctor/p1.cpp
index 7300495c0c..8721dec1b4 100644
--- a/test/CXX/special/class.inhctor/p1.cpp
+++ b/test/CXX/special/class.inhctor/p1.cpp
@@ -49,3 +49,16 @@ B b8{c,0,1};
B b9{"foo"};
// FIXME: explain why the inheriting constructor was deleted
// expected-error@-2 {{call to deleted constructor of 'B'}}
+
+namespace PR15755 {
+ struct X {
+ template<typename...Ts> X(int, Ts...);
+ };
+ struct Y : X {
+ using X::X;
+ };
+ struct Z : Y {
+ using Y::Y;
+ };
+ Z z(0);
+}