diff mbox

C++ PATCH for c++/78198 (inherited template ctor with default arg)

Message ID CADzB+2mrJSe4XdQhToz9rpfXNFG1bbnPfTAGiia=4VRSMVSh6Q@mail.gmail.com
State New
Headers show

Commit Message

Jason Merrill Nov. 4, 2016, 12:46 p.m. UTC
Default arguments of an inherited ctor remain in the context of the
inherited function, not the artificial inheriting constructor.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit d6ceff13167956b660317ef37a40ba7110d325c4
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Nov 3 16:14:51 2016 -0400

            PR c++/78198 - inherited template ctor with default arg
    
            * call.c (convert_default_arg): Look through inheriting ctors.
diff mbox

Patch

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 27aa7fd..d2e99bc 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7193,6 +7193,9 @@  convert_default_arg (tree type, tree arg, tree fn, int parmnum,
 
   /* See through clones.  */
   fn = DECL_ORIGIN (fn);
+  /* And inheriting ctors.  */
+  if (flag_new_inheriting_ctors)
+    fn = strip_inheriting_ctors (fn);
 
   /* Detect recursion.  */
   FOR_EACH_VEC_SAFE_ELT (default_arg_context, i, t)
diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor22.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor22.C
new file mode 100644
index 0000000..1b0e242
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor22.C
@@ -0,0 +1,16 @@ 
+// { dg-do compile { target c++11 } }
+
+class A { };
+template<typename> using UniquePtr = int;
+template<typename AllocPolicy> struct BufferList {
+  BufferList(unsigned, unsigned, unsigned, AllocPolicy = AllocPolicy());
+};
+class D : BufferList<A> {
+  using BufferList::BufferList;
+};
+template<typename , typename... Args> UniquePtr<D> MakeUnique(Args... aArgs)
+{
+  D d(aArgs...);
+  return 0;
+}
+UniquePtr<D> setCloneBuffer_impl_buf = MakeUnique<D>(0, 0, 0);