c++: don't wrap cleanups that can't throw
authorJason Merrill <jason@redhat.com>
Thu, 30 Dec 2021 05:10:57 +0000 (00:10 -0500)
committerJason Merrill <jason@redhat.com>
Sun, 2 Jan 2022 17:56:02 +0000 (12:56 -0500)
commit092e60f57adeccf98e876af6b7b5734337904812
treed1fccee44b5ddfa5581b21987d1cba47133d2463
parent4620531ea988d6d2ede7c8f168074586ba64f482
c++: don't wrap cleanups that can't throw

Since C++11, the vast majority of destructors are noexcept, so
wrap_temporary_cleanups adds a bunch of useless TRY_CATCH_EXPR to be removed
later in the optimizers.  It's simple to avoid adding them in the first
place.

gcc/cp/ChangeLog:

* decl.c (wrap_cleanups_r): Don't wrap if noexcept.

gcc/testsuite/ChangeLog:

* g++.dg/eh/cleanup6.C: New test.
gcc/cp/decl.c
gcc/testsuite/g++.dg/eh/cleanup6.C [new file with mode: 0644]