Author: cor3ntin Date: 2024-12-09T10:20:16+01:00 New Revision: 6d759f83eb779cfdec02c1fe33344f3215bbdab1
URL: https://github.com/llvm/llvm-project/commit/6d759f83eb779cfdec02c1fe33344f3215bbdab1 DIFF: https://github.com/llvm/llvm-project/commit/6d759f83eb779cfdec02c1fe33344f3215bbdab1.diff LOG: [Clang] Deleting an incomplete enum type is not an error (#119077) The changes introduced in #97733 accidentally prevented to delete an incomplete enum (the validity of which has been confirmed by CWG2925 Fixes #99278 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaExprCXX.cpp clang/test/SemaCXX/new-delete.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 95007f357b766f..7d846f1d447d16 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -799,6 +799,7 @@ Bug Fixes to C++ Support - Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205) - Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda captures at the end of a full expression. (#GH115931) +- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index f58c0fa21e8380..caea13b192ad57 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3747,7 +3747,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, } else if (!Pointee->isDependentType()) { // FIXME: This can result in errors if the definition was imported from a // module but is hidden. - if (!RequireCompleteType(StartLoc, Pointee, + if (Pointee->isEnumeralType() || + !RequireCompleteType(StartLoc, Pointee, LangOpts.CPlusPlus26 ? diag::err_delete_incomplete : diag::warn_delete_incomplete, diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp index 595bdc689d694b..fb4810ad673ad2 100644 --- a/clang/test/SemaCXX/new-delete.cpp +++ b/clang/test/SemaCXX/new-delete.cpp @@ -540,6 +540,22 @@ namespace PR10504 { void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}} } +#if __cplusplus >= 201103L +enum GH99278_1 { + zero = decltype(delete static_cast<GH99278_1*>(nullptr), 0){} + // expected-warning@-1 {{expression with side effects has no effect in an unevaluated context}} +}; +template <typename = void> +struct GH99278_2 { + union b {}; + struct c { + c() { delete d; } + b *d; + } f; +}; +GH99278_2<void> e; +#endif + struct PlacementArg {}; inline void *operator new[](size_t, const PlacementArg &) throw () { return 0; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits