Skip to content

Commit f463154

Browse files
committed
Fix think-o and add test coverage to ensure it doesn't happen again
1 parent 1de3f1f commit f463154

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clang/lib/Sema/SemaExceptionSpec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,8 +1206,8 @@ CanThrowResult Sema::canThrow(const Stmt *S) {
12061206
CT = CT_Dependent;
12071207
} else {
12081208
const FunctionDecl *OperatorDelete = DE->getOperatorDelete();
1209+
CT = canCalleeThrow(*this, DE, OperatorDelete);
12091210
if (!OperatorDelete->isDestroyingOperatorDelete()) {
1210-
CT = canCalleeThrow(*this, DE, OperatorDelete);
12111211
if (const RecordType *RT = DTy->getAs<RecordType>()) {
12121212
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
12131213
const CXXDestructorDecl *DD = RD->getDestructor();

clang/test/SemaCXX/noexcept-destroying-delete.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ struct Explicit {
1919
Explicit *qn = nullptr;
2020
// This assertion used to fail, see GH118660
2121
static_assert(noexcept(delete(qn)));
22+
23+
struct ThrowingDestroyingDelete {
24+
~ThrowingDestroyingDelete() noexcept(false) {}
25+
26+
void operator delete(ThrowingDestroyingDelete*, std::destroying_delete_t) noexcept(false) {
27+
}
28+
};
29+
30+
ThrowingDestroyingDelete *pn = nullptr;
31+
// noexcept should return false here because the destroying delete itself is a
32+
// potentially throwing function.
33+
static_assert(!noexcept(delete(pn)));

0 commit comments

Comments
 (0)