llvm-project/clang/test/SemaCXX/cxx1y-sized-deallocation.cpp
Pengcheng Wang 130e93cc26
Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373)
Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061
2024-05-22 12:37:27 +08:00

20 lines
694 B
C++

// RUN: %clang_cc1 -std=c++1y -verify %s -fexceptions -fcxx-exceptions
using size_t = decltype(sizeof(0));
void operator delete(void *, size_t) noexcept; // expected-note {{'operator delete' declared here}}
void operator delete[](void *, size_t) noexcept;
void f(void *p, void *q) {
// OK, implicitly declared.
operator delete(p, 8);
operator delete[](q, 12);
static_assert(noexcept(operator delete(p, 8)), "");
static_assert(noexcept(operator delete[](q, 12)), "");
}
void *operator new(size_t bad, size_t idea);
struct S { S() { throw 0; } };
void g() {
new (123) S; // expected-error {{'new' expression with placement arguments refers to non-placement 'operator delete'}}
}