-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] fix assertion failure in invalid delete operator declaration check #99308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) ChangesFixes #96191 Full diff: https://github.com/llvm/llvm-project/pull/99308.diff 3 Files Affected:
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; }
+}
|
@AaronBallman could you review this PR? thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for the fix!
@AaronBallman If no further feedback is needed, could you please proceed with the merge? Thanks |
Can do! Btw, you should feel free to obtain commit privileges yourself if you'd like: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access |
@AaronBallman Thanks |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/2579 Here is the relevant piece of the build log for the reference:
|
…check (#99308) Summary: Fixes #96191 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250558
Fixes #96191