c++: ICE on unviable/ambiguous constrained dtors [PR96745]
commited2b519e02eac99fadfa51adc7b11f8854c24575
authorPatrick Palka <ppalka@redhat.com>
Fri, 3 Feb 2023 14:15:29 +0000 (3 09:15 -0500)
committerPatrick Palka <ppalka@redhat.com>
Fri, 3 Feb 2023 14:15:29 +0000 (3 09:15 -0500)
treece8bb184a383d8d5b228d7c220ba95b3875223aa
parente7930c6750d03b28d922ebbbace20ba9d8622c6a
c++: ICE on unviable/ambiguous constrained dtors [PR96745]

Here we're crashing from check_bases_and_members due to
CLASSTYPE_DESTRUCTOR being an OVERLOAD which, due to the pruning
performed by add_method, should only happen if there is no viable
destructor or the destructor is ambiguous because of unsatisfied
or ambiguous constraints.

This patch fixes this by making check_bases_and_members naturally handle
CLASSTYPE_DESTRUCTOR being an OVERLOAD.  It's then convenient to prune
the OVERLOAD after effectively diagnosing the overload resolution
failure in check_methods.

PR c++/96745

gcc/cp/ChangeLog:

* class.cc (check_methods): Diagnose an unviable OVERLOAD
set for CLASSTYPE_DESTRUCTOR differently from an ambiguous one.
Then prune the OVERLOAD to a single function.
(check_bases_and_members): Handle CLASSTYPE_DESTRUCTOR being
an OVERLOAD when calling deduce_noexcept_on_destructor.
Document why it has to be called before check_methods.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-dtor1.C: New test.
gcc/cp/class.cc
gcc/testsuite/g++.dg/cpp2a/concepts-dtor1.C [new file with mode: 0644]