1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // struct destroying_delete_t {
11 // explicit destroying_delete_t() = default;
13 // inline constexpr destroying_delete_t destroying_delete{};
15 // UNSUPPORTED: c++03, c++11, c++14, c++17
17 // UNSUPPORTED: apple-clang-9, apple-clang-10
18 // UNSUPPORTED: clang-6, clang-7
23 #include "test_macros.h"
31 void operator delete(A
*, std::destroying_delete_t
);
34 bool A_constructed
= false;
35 bool A_destroyed
= false;
36 bool A_destroying_deleted
= false;
47 return new(::operator new(sizeof(A
))) A();
50 void A::operator delete(A
* a
, std::destroying_delete_t
) {
51 A_destroying_deleted
= true;
55 // Only test the definition of the library feature-test macro when the compiler
56 // supports the feature -- otherwise we don't define the library feature-test
58 #if defined(__cpp_impl_destroying_delete)
59 # if !defined(__cpp_lib_destroying_delete)
60 # error "Expected __cpp_lib_destroying_delete to be defined"
61 # elif __cpp_lib_destroying_delete < 201806L
62 # error "Unexpected value of __cpp_lib_destroying_delete"
65 # if defined(__cpp_lib_destroying_delete)
66 # error "The library feature-test macro for destroying delete shouldn't be defined when the compiler doesn't support the language feature"
70 int main(int, char**) {
71 // Ensure that we call the destroying delete and not the destructor.
73 assert(A_constructed
);
76 assert(A_destroying_deleted
);