[clang] f916cb6 - [Clang] fix assertion failure in invalid delete operator declaration check (#99308)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 25 05:08:22 PDT 2024
Author: Oleksandr T.
Date: 2024-07-25T08:08:18-04:00
New Revision: f916cb6184fb04b27ae7b867edcfd162c3a49694
URL: https://github.com/llvm/llvm-project/commit/f916cb6184fb04b27ae7b867edcfd162c3a49694
DIFF: https://github.com/llvm/llvm-project/commit/f916cb6184fb04b27ae7b867edcfd162c3a49694.diff
LOG: [Clang] fix assertion failure in invalid delete operator declaration check (#99308)
Fixes #96191
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/cxx2a-destroying-delete.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0b79e952b48af..9f5ee9c82ab0a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 14d1f395af90e..51c4a36808fce 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -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.
diff --git a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
index 349e6e9538a4c..25b985ef11d15 100644
--- a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
+++ b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
@@ -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; }
+}
More information about the cfe-commits
mailing list