c++: constexpr error with defaulted virtual dtor [PR93413]
authorPatrick Palka <ppalka@redhat.com>
Thu, 3 Nov 2022 18:55:35 +0000 (14:55 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 3 Nov 2022 18:55:35 +0000 (14:55 -0400)
commitc0b38e9fec71dc4cc5e99b1f0cb159c15a8da9ba
treefcb8632e8648eb54eb5bfacd9cc07d71cafad8c3
parentdb6a9fe39ab08526b920af2b233b06860d286943
c++: constexpr error with defaulted virtual dtor [PR93413]

We're rejecting the below testcase with

  error: 'virtual constexpr Base::~Base()' used before its definition
  error: 'virtual constexpr Derived::~Derived()' used before its definition

due to special handling in mark_used added by r181272 to defer synthesis
of virtual destructors until EOF (where we can set their linkage), which
in turn makes them effectively unusable during constexpr evaluation.

Fortunately it seems this special handling is unnecessary ever since
r208030 enabled us to tentatively set linkage of all defaulted virtual
destructors, including templated ones.  So this patch gets rid of this
special handling.

PR c++/93413

gcc/cp/ChangeLog:

* decl2.cc (mark_used): Don't defer synthesis of virtual
functions.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-virtual21.C: New test.
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C [new file with mode: 0644]