From 2dc1070584c5d700ab878fa13a18e2e25f0380c8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 20 Jul 2019 10:43:49 -0400 Subject: [PATCH] Fix ICE on class template argument deduction with inherited ctor. 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 | 5 +++++ gcc/cp/cp-tree.h | 3 ++- .../g++.dg/cpp1z/class-deduction67.C | 21 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction67.C 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 + + * cp-tree.h (ovl_iterator::using_p): A USING_DECL by itself was also + introduced by a using-declaration. + 2019-07-20 Jason Merrill Reduce memory consumption for push/pop_access_scope. 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 struct A +{ + A(T); +}; + +template struct B: A +{ + using A::A; +}; + +int main() +{ + B b = 42; // { dg-line init } + // { dg-prune-output "no matching function" } + // { dg-error "class template argument deduction" "" { target *-*-* } init } +} -- 2.30.2