[clang] [Clang] fix assertion failure in invalid delete operator declaration check (PR #99308)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 17 04:28:08 PDT 2024
https://github.com/a-tarasyuk created https://github.com/llvm/llvm-project/pull/99308
Fixes #96191
>From 39de759ac60f2f06953ebe32392c25837ba591f1 Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Wed, 17 Jul 2024 14:21:31 +0300
Subject: [PATCH] [Clang] fix assertion failure in invalid delete operator
declaration check
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/Sema/SemaExprCXX.cpp | 3 +++
clang/test/SemaCXX/cxx2a-destroying-delete.cpp | 9 +++++++++
3 files changed, 13 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6dc45956a9afb..ed99f3796ad34 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1043,6 +1043,7 @@ Bug Fixes to C++ Support
- Clang now diagnoses explicit object parameters in member pointers and other contexts where they should not appear.
Fixes (#GH85992).
- Fixed a crash-on-invalid bug involving extraneous template parameter with concept substitution. (#GH73885)
+- 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 bef7da239e6e5..c581a3448e927 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