Skip to content

Commit

Permalink
[Clang] fix assertion failure in invalid delete operator declaration …
Browse files Browse the repository at this point in the history
…check (llvm#99308)

Fixes llvm#96191
  • Loading branch information
a-tarasyuk authored Jul 25, 2024
1 parent fc9b9e8 commit f916cb6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^

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

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3806,6 +3806,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
Overaligned, DeleteName);
}

if (OperatorDelete->isInvalidDecl())
return ExprError();

MarkFunctionReferenced(StartLoc, OperatorDelete);

// Check access and ambiguity of destructor if we're going to call it.
Expand Down
9 changes: 9 additions & 0 deletions clang/test/SemaCXX/cxx2a-destroying-delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,12 @@ namespace delete_from_new {
#endif
}
}

namespace GH96191 {
struct S {};
struct T {
void operator delete(S) { } // expected-error {{first parameter of 'operator delete' must have type 'void *'}}
};

void foo(T *t) { delete t; }
}

0 comments on commit f916cb6

Please sign in to comment.