]> granicus.if.org Git - clang/commitdiff
PR15755: don't drop parameter packs when dropping parameters with default
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 17 Apr 2013 19:00:52 +0000 (19:00 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 17 Apr 2013 19:00:52 +0000 (19:00 +0000)
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
test/CXX/special/class.inhctor/p1.cpp

index fd3489fd537be199a5a467a13b1769493026da5a..94a507449b9e77d320ede8cd5b5b0a24cbf21275 100644 (file)
@@ -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
index 7300495c0c074f26658199ace66bbe4821ec1f57..8721dec1b40597e3a683f874523edf2da046fade 100644 (file)
@@ -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);
+}