aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-07-20 10:43:49 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-07-20 10:43:49 -0400
commit2dc1070584c5d700ab878fa13a18e2e25f0380c8 (patch)
treede3478d6add3f50cb727ad27e7ed04056bee0786
parent1ab1f3502038323f6f5cd8c16c0ac1b1416e3545 (diff)
downloadgcc-2dc1070584c5d700ab878fa13a18e2e25f0380c8.zip
gcc-2dc1070584c5d700ab878fa13a18e2e25f0380c8.tar.gz
gcc-2dc1070584c5d700ab878fa13a18e2e25f0380c8.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cp-tree.h3
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction67.C21
3 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0c6a7de..d645cde 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
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.
* name-lookup.c (leave_scope): Do add class levels other than
previous_class_level to free_binding_level.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6068745..688924c 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 0000000..4624794
--- /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 }
+}