From b9e03679808ef26ba9614d352f69a347df120265 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 17 Jan 2019 17:07:20 +0000 Subject: [PATCH] C++: Fix ICE when adding overloaded operator via using_decl (PR c++/88699) PR c++/88699 reports an ICE within this assertion in add_method: gcc_assert (!current_fns || !DECL_DESTRUCTOR_P (method)); when adding an overloaded operator to a class via a using_decl, due to DECL_DESTRUCTOR_P requiring a FUNCTION_DECL, but "method" being a USING_DECL. This patch weakens the assertion to avoid testing DECL_DESTRUCTOR_P for the case where "via_using" is true, fixing the ICE. gcc/cp/ChangeLog: PR c++/88699 * class.c (add_method): Don't use DECL_DESTRUCTOR_P on USING_DECLs. gcc/testsuite/ChangeLog: PR c++/88699 * g++.dg/template/pr88699.C: New test. From-SVN: r268041 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/class.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/pr88699.C | 13 +++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/pr88699.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dec8d64..6893b2e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-01-17 David Malcolm + + PR c++/88699 + * class.c (add_method): Don't use DECL_DESTRUCTOR_P on + USING_DECLs. + 2019-01-17 Nathan Sidwell PR c++/86610 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index e7897f2..e8773c2 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1134,7 +1134,7 @@ add_method (tree type, tree method, bool via_using) } /* A class should never have more than one destructor. */ - gcc_assert (!current_fns || !DECL_DESTRUCTOR_P (method)); + gcc_assert (!current_fns || via_using || !DECL_DESTRUCTOR_P (method)); current_fns = ovl_insert (method, current_fns, via_using); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 31b171b..176d2f8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-17 David Malcolm + + PR c++/88699 + * g++.dg/template/pr88699.C: New test. + 2019-01-17 Martin Sebor PR tree-optimization/88800 diff --git a/gcc/testsuite/g++.dg/template/pr88699.C b/gcc/testsuite/g++.dg/template/pr88699.C new file mode 100644 index 0000000..ecd26ce --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr88699.C @@ -0,0 +1,13 @@ +// { dg-do compile } + +template +struct A { + void operator= (int); + template class B; +}; +template +template +struct A::B : A { + using A::operator=; + void operator= (B); +}; -- 2.7.4