]> git.ipfire.org Git - thirdparty/gcc.git/commit
C++ concepts: fix ICE with requires on dtors (PR c++/89036)
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Feb 2019 15:48:37 +0000 (15:48 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Feb 2019 15:48:37 +0000 (15:48 +0000)
commitf2da1a764fb7e706bcd1b9975ecd024dbfd02756
tree838b1c00a49568f1bf793a8e4e40340d7aeb611e
parenta7f0b0f652bb6d3cab3fe1beb0fa13a3c3a8ac73
C++ concepts: fix ICE with requires on dtors (PR c++/89036)

PR c++/89036 reports an ICE due to this assertion failing

1136   /* A class should never have more than one destructor.  */
1137   gcc_assert (!current_fns || via_using || !DECL_DESTRUCTOR_P (method));

on this template with a pair of dtors, with
mutually exclusive "requires" clauses:

template<typename T>
struct Y {
    ~Y() requires(true) = default;
    ~Y() requires(false) {}
};

Nathan introduced this assertion as part of:

  ca9219bf18c68a001d62ecb981bc9176b0feaf12 (aka r251340):
    2017-08-24  Nathan Sidwell  <nathan@acm.org>
       Conversion operators kept on single overload set

which, amongst other changes to add_method had this:
     /* A class should never have more than one destructor.  */
  -  if (current_fns && DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (method))
  -    return false;
  +  gcc_assert (!current_fns || !DECL_DESTRUCTOR_P (method));

The following patch drops the assertion (I already had to generalize
the assertion in r268041 to fix PR c++/88699).

gcc/cp/ChangeLog:
PR c++/89036
* class.c (add_method): Drop destructor assertion.

gcc/testsuite/ChangeLog:
PR c++/89036
* g++.dg/concepts/pr89036.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268847 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/concepts/pr89036.C [new file with mode: 0644]