r179708 - PR15755: don't drop parameter packs when dropping parameters with default
Richard Smith
richard-llvm at metafoo.co.uk
Wed Apr 17 12:00:52 PDT 2013
Author: rsmith
Date: Wed Apr 17 14:00:52 2013
New Revision: 179708
URL: http://llvm.org/viewvc/llvm-project?rev=179708&view=rev
Log:
PR15755: don't drop parameter packs when dropping parameters with default
arguments in the formation of a candidate set of inheriting constructors.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/special/class.inhctor/p1.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=179708&r1=179707&r2=179708&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Apr 17 14:00:52 2013
@@ -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
Modified: cfe/trunk/test/CXX/special/class.inhctor/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.inhctor/p1.cpp?rev=179708&r1=179707&r2=179708&view=diff
==============================================================================
--- cfe/trunk/test/CXX/special/class.inhctor/p1.cpp (original)
+++ cfe/trunk/test/CXX/special/class.inhctor/p1.cpp Wed Apr 17 14:00:52 2013
@@ -49,3 +49,16 @@ B b8{c,0,1};
B b9{"foo"};
// FIXME: explain why the inheriting constructor was deleted
// expected-error at -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);
+}
More information about the cfe-commits
mailing list