CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
// RUN: %clang_cc1 -std=c++20 -verify %s
|
|
|
|
using size_t = decltype(sizeof(0));
|
|
namespace std {
|
|
enum class align_val_t : size_t {};
|
|
struct destroying_delete_t {
|
|
explicit destroying_delete_t() = default;
|
|
};
|
|
|
|
inline constexpr destroying_delete_t destroying_delete{};
|
|
}
|
|
|
|
// Aligned version is preferred over unaligned version,
|
|
// unsized version is preferred over sized version.
|
|
template<unsigned Align>
|
|
struct alignas(Align) A {
|
|
void operator delete(void*);
|
|
void operator delete(void*, std::align_val_t) = delete; // expected-note {{here}}
|
|
|
|
void operator delete(void*, size_t) = delete;
|
|
void operator delete(void*, size_t, std::align_val_t) = delete;
|
|
};
|
|
void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; }
|
|
void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}}
|
|
|
|
template<unsigned Align>
|
|
struct alignas(Align) B {
|
|
void operator delete(void*, size_t);
|
|
void operator delete(void*, size_t, std::align_val_t) = delete; // expected-note {{here}}
|
|
};
|
|
void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; }
|
|
void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}}
|
|
|
|
// Ensure that a deleted destructor is acceptable when the selected overload
|
|
// for operator delete is a destroying delete. See the comments in GH118660.
|
|
struct S {
|
|
~S() = delete;
|
|
void operator delete(S *, std::destroying_delete_t) noexcept {}
|
|
};
|
|
|
|
struct T {
|
|
void operator delete(T *, std::destroying_delete_t) noexcept {}
|
|
private:
|
|
~T();
|
|
};
|
|
|
|
void foo(S *s, T *t) {
|
|
delete s; // Was rejected, is intended to be accepted.
|
|
delete t; // Was rejected, is intended to be accepted.
|
|
}
|
|
|
|
// However, if the destructor is virtual, then it has to be accessible because
|
|
// the behavior depends on which operator delete is selected and that is based
|
|
// on the dynamic type of the pointer.
|
|
struct U {
|
|
virtual ~U() = delete; // expected-note {{here}}
|
|
void operator delete(U *, std::destroying_delete_t) noexcept {}
|
|
};
|
|
|
|
struct V {
|
|
void operator delete(V *, std::destroying_delete_t) noexcept {}
|
|
private:
|
|
virtual ~V(); // expected-note {{here}}
|
|
};
|
|
|
|
void bar(U *u, V *v) {
|
|
// Both should be rejected because they have virtual destructors.
|
|
delete u; // expected-error {{attempt to use a deleted function}}
|
|
delete v; // expected-error {{calling a private destructor of class 'V'}}
|
|
}
|