PR c++/82152 - ICE with class deduction and inherited ctor.
authorJason Merrill <jason@redhat.com>
Thu, 5 Apr 2018 16:42:09 +0000 (12:42 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 5 Apr 2018 16:42:09 +0000 (12:42 -0400)
* pt.c (do_class_deduction): Ignore inherited ctors.

From-SVN: r259133

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/class-deduction54.C [new file with mode: 0644]

index b453577fa14b699f68b2a8b2f2338cec5650075e..a876dc9bffdf74e0cc53d2c9c4746c9f7e86a7fa 100644 (file)
@@ -1,5 +1,8 @@
 2018-04-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/82152 - ICE with class deduction and inherited ctor.
+       * pt.c (do_class_deduction): Ignore inherited ctors.
+
        PR c++/84665 - ICE with array of empty class.
        * decl2.c (cp_check_const_attributes): Use fold_non_dependent_expr.
 
index dc74635876e2839d6ffb9eccdc1479b2f9768a11..dc2310aefa8540e9ff44addf499be52b95ca25bb 100644 (file)
@@ -26217,6 +26217,10 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
   // FIXME cache artificial deduction guides
   for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); iter; ++iter)
     {
+      /* Skip inherited constructors.  */
+      if (iter.using_p ())
+       continue;
+
       tree guide = build_deduction_guide (*iter, outer_args, complain);
       if (guide == error_mark_node)
        return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C
new file mode 100644 (file)
index 0000000..e51398b
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/82152
+// { dg-additional-options -std=c++17 }
+
+struct Base {};
+
+template<typename T>
+struct Derived : public Base {
+  using Base::Base;
+};
+
+Derived() -> Derived< void >;
+
+int main() {
+  Derived x;
+}