PR c++/78767 - ICE with inherited constructor default argument
authorJason Merrill <jason@redhat.com>
Wed, 21 Dec 2016 19:10:23 +0000 (14:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 21 Dec 2016 19:10:23 +0000 (14:10 -0500)
* method.c (strip_inheriting_ctors): Strip template as appropriate.

From-SVN: r243864

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C [new file with mode: 0644]

index c4c51719374758b8f6f7bad907ea3ae9802ac35d..1b14e1980c8a0db1369bf56ae33f55ff6f777b0f 100644 (file)
@@ -1,5 +1,8 @@
 2016-12-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/78767 - ICE with inherited constructor default argument
+       * method.c (strip_inheriting_ctors): Strip template as appropriate.
+
        PR c++/78749 - friend in anonymous namespace
        * decl.c (wrapup_globals_for_namespace): Don't complain about friend
        pseudo-template instantiations.
index 73d42b19d55af4aa45f68072eb84a078d2721369..a5271a443cfd92eb9e9c6e7baaaeab0c366bfc86 100644 (file)
@@ -496,14 +496,18 @@ forward_parm (tree parm)
    constructor from a (possibly indirect) base class.  */
 
 tree
-strip_inheriting_ctors (tree fn)
+strip_inheriting_ctors (tree dfn)
 {
   gcc_assert (flag_new_inheriting_ctors);
+  tree fn = dfn;
   while (tree inh = DECL_INHERITED_CTOR (fn))
     {
       inh = OVL_CURRENT (inh);
       fn = inh;
     }
+  if (TREE_CODE (fn) == TEMPLATE_DECL
+      && TREE_CODE (dfn) == FUNCTION_DECL)
+    fn = DECL_TEMPLATE_RESULT (fn);
   return fn;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C
new file mode 100644 (file)
index 0000000..7c1fae0
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/78767
+// { dg-do compile { target c++11 } }
+
+template <class T> struct A
+{
+  template <class U>
+  A(U, U = 42);
+};
+
+struct B: A<int>
+{
+  using A::A;
+};
+
+B b(24);