Author: Timm Baeder Date: 2026-05-30T17:20:42+02:00 New Revision: 470411cf18e33fe461f7207831604f989a7a6e61
URL: https://github.com/llvm/llvm-project/commit/470411cf18e33fe461f7207831604f989a7a6e61 DIFF: https://github.com/llvm/llvm-project/commit/470411cf18e33fe461f7207831604f989a7a6e61.diff LOG: [clang][bytecode] Loosen an assertion about operator delete (#200575) We may also see OO_Array_Delete here. Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/AST/ByteCode/new-delete.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 70507d577dd11..774a853950837 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -5733,7 +5733,9 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) { if (FuncDecl->isUsableAsGlobalAllocationFunctionInConstantEvaluation()) { if (FuncDecl->getDeclName().isAnyOperatorNew()) return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_new); - assert(FuncDecl->getDeclName().getCXXOverloadedOperator() == OO_Delete); + assert(FuncDecl->getDeclName().getCXXOverloadedOperator() == OO_Delete || + FuncDecl->getDeclName().getCXXOverloadedOperator() == + OO_Array_Delete); return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_delete); } diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp index 930e090dd5bce..f31851c98213c 100644 --- a/clang/test/AST/ByteCode/new-delete.cpp +++ b/clang/test/AST/ByteCode/new-delete.cpp @@ -1220,6 +1220,21 @@ namespace ArrayDestSize { static_assert(dynarray<char>(3, 2) == 'x'); // both-error {{constant expression}} both-note {{in call}} } +namespace OpertorArrayDelete { + struct S {}; + using State = S[2]; + constexpr unsigned run(const State *s) { + void *p; + p = operator new[](128); // both-note {{cannot allocate untyped memory}} + operator delete[](p); + return 42; + } + + constexpr State s[] = {}; + static_assert(run(s) == 42, ""); // both-error {{not an integral constant expression}} \ + // both-note {{in call to}} +} + #else /// Make sure we reject this prior to C++20 constexpr int a() { // both-error {{never produces a constant expression}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
