Skip to content

Commit 8271195

Browse files
authored
[Clang] Deleting an incomplete enum type is not an error (#118455)
The changes introduced in #97733 accidentally prevented to delete an incomplete enum (the validity of which has been confirmed by CWG2925 Fixes #99278
1 parent 2e85138 commit 8271195

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ Bug Fixes to C++ Support
770770
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
771771
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
772772
captures at the end of a full expression. (#GH115931)
773+
- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278)
773774

774775
Bug Fixes to AST Handling
775776
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
37473747
} else if (!Pointee->isDependentType()) {
37483748
// FIXME: This can result in errors if the definition was imported from a
37493749
// module but is hidden.
3750-
if (!RequireCompleteType(StartLoc, Pointee,
3750+
if (!Pointee->isStructureOrClassType() ||
3751+
!RequireCompleteType(StartLoc, Pointee,
37513752
LangOpts.CPlusPlus26
37523753
? diag::err_delete_incomplete
37533754
: diag::warn_delete_incomplete,

clang/test/SemaCXX/new-delete.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,13 @@ namespace PR10504 {
540540
void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}}
541541
}
542542

543+
#if __cplusplus >= 201103L
544+
enum GH99278_1 {
545+
zero = decltype(delete static_cast<GH99278_1*>(nullptr), 0){}
546+
// expected-warning@-1 {{expression with side effects has no effect in an unevaluated context}}
547+
};
548+
#endif
549+
543550
struct PlacementArg {};
544551
inline void *operator new[](size_t, const PlacementArg &) throw () {
545552
return 0;

0 commit comments

Comments
 (0)