From 987c03085558277a5fe8cef8e1b628cabcc626dc Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 17 Apr 2013 19:00:52 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaDeclCXX.cpp | 17 ++++++++++------- test/CXX/special/class.inhctor/p1.cpp | 13 +++++++++++++ 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 X(int, Ts...); + }; + struct Y : X { + using X::X; + }; + struct Z : Y { + using Y::Y; + }; + Z z(0); +} -- 2.40.0