]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix ICE on class template argument deduction with inherited ctor.
authorJason Merrill <jason@redhat.com>
Sat, 20 Jul 2019 14:43:49 +0000 (10:43 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 20 Jul 2019 14:43:49 +0000 (10:43 -0400)
In general, when we see a dependent using-declaration we don't know whether
it names a function or not, so it doesn't get an OVERLOAD unless we see
overloads of the same name in the current class.  In the case of an
inherited constructor we could figure that out from the name, but it's
simpler to handle USING_DECL properly.

* cp-tree.h (ovl_iterator::using_p): A USING_DECL by itself was also
introduced by a using-declaration.

From-SVN: r273623

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/testsuite/g++.dg/cpp1z/class-deduction67.C [new file with mode: 0644]

index 0c6a7de94d92e214abea716b4653d951bd93364d..d645cdef147be15f212ddbc2ee0a514d4b3edb13 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-20  Jason Merrill  <jason@redhat.com>
+
+       * cp-tree.h (ovl_iterator::using_p): A USING_DECL by itself was also
+       introduced by a using-declaration.
+
 2019-07-20  Jason Merrill  <jason@redhat.com>
 
        Reduce memory consumption for push/pop_access_scope.
index 6068745567a70621ef694e2bd1434e7550cddc0d..688924cdd12d1465f417530aec2a7956914d1d3b 100644 (file)
@@ -774,7 +774,8 @@ class ovl_iterator
   /* Whether this overload was introduced by a using decl.  */
   bool using_p () const
   {
-    return TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl);
+    return (TREE_CODE (ovl) == USING_DECL
+           || (TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl)));
   }
   bool hidden_p () const
   {
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction67.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction67.C
new file mode 100644 (file)
index 0000000..4624794
--- /dev/null
@@ -0,0 +1,21 @@
+// Deduction from inherited constructors isn't supported yet, but we shouldn't
+// crash.  It may well be supported in C++23.
+
+//{ dg-do compile { target c++17 } }
+
+template <class T> struct A
+{
+  A(T);
+};
+
+template <class T> struct B: A<T>
+{
+  using A<T>::A;
+};
+
+int main()
+{
+  B b = 42;                    // { dg-line init }
+  // { dg-prune-output "no matching function" }
+  // { dg-error "class template argument deduction" "" { target *-*-* } init }
+}