2016-12-19 Nathan Sidwell <nathan@acm.org>
PR c++/78771
* pt.c (instantiate_template_1): Check for recursive instantiation
of inheriting constructor.
PR c++/78771
* g++.dg/cpp0x/pr78771.C: New.
===================================================================
@@ -17717,10 +17717,22 @@ instantiate_template_1 (tree tmpl, tree
if (spec == error_mark_node)
return error_mark_node;
+ /* If this is an inherited ctor, we can recursively clone it
+ when deducing the validity of the ctor. But we won't have
+ cloned the function yet, so do it now. We'll redo this
+ later, but any recursive information learnt here can't
+ change the validity. */
+ if (!TREE_CHAIN (spec))
+ {
+ gcc_assert (DECL_INHERITED_CTOR (spec));
+ clone_function_decl (spec, /*update_method_vec_p=*/0);
+ }
+
/* Look for the clone. */
FOR_EACH_CLONE (clone, spec)
if (DECL_NAME (clone) == DECL_NAME (tmpl))
return clone;
+
/* We should always have found the clone by now. */
gcc_unreachable ();
return NULL_TREE;
===================================================================
@@ -0,0 +1,27 @@
+// PR c++/78771
+// { dg-do compile { target c++11 } }
+
+// ICE instantiating a deleted inherited ctor
+
+struct Base
+{
+ template <typename U> Base (U);
+
+ Base (int);
+};
+
+struct Derived;
+
+struct Middle : Base
+{
+ using Base::Base;
+
+ Middle (Derived);
+};
+
+struct Derived : Middle
+{
+ using Middle::Middle;
+};
+
+Middle::Middle (Derived) : Middle (0) {}