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.

Tested x86_64-pc-linux-gnu, applying to trunk.

        * cp-tree.h (ovl_iterator::using_p): A USING_DECL by itself was also
        introduced by a using-declaration.
---
 gcc/cp/cp-tree.h                              |  3 ++-
 .../g++.dg/cpp1z/class-deduction67.C          | 21 +++++++++++++++++++
 gcc/cp/ChangeLog                              |  5 +++++
 3 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction67.C

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6068745567a..688924cdd12 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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
index 00000000000..4624794c4b7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction67.C
@@ -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 }
+}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0c6a7de94d9..d645cdef147 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-20  Jason Merrill  <ja...@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  <ja...@redhat.com>
 
        Reduce memory consumption for push/pop_access_scope.

base-commit: 8086cf948309ce8a2a353e0d483b9a14c9f83cc6
-- 
2.21.0

Reply via email to