Skip to content

Commit f916cb6

Browse files
authored
[Clang] fix assertion failure in invalid delete operator declaration check (#99308)
Fixes #96191
1 parent fc9b9e8 commit f916cb6

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Bug Fixes to C++ Support
150150
^^^^^^^^^^^^^^^^^^^^^^^^
151151

152152
- Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646)
153+
- Fixed a failed assertion when checking invalid delete operator declaration. (#GH96191)
153154

154155
Bug Fixes to AST Handling
155156
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,6 +3806,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
38063806
Overaligned, DeleteName);
38073807
}
38083808

3809+
if (OperatorDelete->isInvalidDecl())
3810+
return ExprError();
3811+
38093812
MarkFunctionReferenced(StartLoc, OperatorDelete);
38103813

38113814
// Check access and ambiguity of destructor if we're going to call it.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,12 @@ namespace delete_from_new {
187187
#endif
188188
}
189189
}
190+
191+
namespace GH96191 {
192+
struct S {};
193+
struct T {
194+
void operator delete(S) { } // expected-error {{first parameter of 'operator delete' must have type 'void *'}}
195+
};
196+
197+
void foo(T *t) { delete t; }
198+
}

0 commit comments

Comments
 (0)