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
70 lines
3.6 KiB
C++
70 lines
3.6 KiB
C++
// RUN: %clang_cc1 -std=c++1z -fexceptions %s -verify
|
|
|
|
using size_t = decltype(sizeof(0));
|
|
namespace std { enum class align_val_t : size_t {}; }
|
|
|
|
struct Arg {} arg;
|
|
|
|
// If the type is aligned, first try with an alignment argument and then
|
|
// without. If not, never consider supplying an alignment.
|
|
|
|
template<unsigned Align, typename ...Ts>
|
|
struct alignas(Align) Unaligned {
|
|
void *operator new(size_t, Ts...) = delete; // expected-note 4{{deleted}}
|
|
};
|
|
auto *ua = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}}
|
|
auto *ub = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}}
|
|
auto *uap = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}}
|
|
auto *ubp = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}}
|
|
|
|
template<unsigned Align, typename ...Ts>
|
|
struct alignas(Align) Aligned {
|
|
void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}} expected-note 2{{not viable}}
|
|
};
|
|
auto *aa = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{no matching}}
|
|
auto *ab = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}}
|
|
auto *aap = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{no matching}}
|
|
auto *abp = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}}
|
|
|
|
// If both are available, we prefer the aligned version for an overaligned
|
|
// type, and only use the unaligned version for a non-overaligned type.
|
|
|
|
template<unsigned Align, typename ...Ts>
|
|
struct alignas(Align) Both1 {
|
|
void *operator new(size_t, Ts...); // expected-note 2{{not viable}}
|
|
void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}}
|
|
};
|
|
template<unsigned Align, typename ...Ts>
|
|
struct alignas(Align) Both2 {
|
|
void *operator new(size_t, Ts...) = delete; // expected-note 2{{deleted}}
|
|
void *operator new(size_t, std::align_val_t, Ts...); // expected-note 2{{not viable}}
|
|
};
|
|
auto *b1a = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__>;
|
|
auto *b1b = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}}
|
|
auto *b2a = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}}
|
|
auto *b2b = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>;
|
|
auto *b1ap = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>;
|
|
auto *b1bp = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}}
|
|
auto *b2ap = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}}
|
|
auto *b2bp = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>;
|
|
|
|
// Note that the aligned form can select a function with a parameter different
|
|
// from std::align_val_t.
|
|
|
|
struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc1 {
|
|
void *operator new(size_t, ...) = delete; // expected-note 2{{deleted}}
|
|
};
|
|
auto *waa1 = new WeirdAlignedAlloc1; // expected-error {{deleted}}
|
|
auto *waa1p = new (arg) WeirdAlignedAlloc1; // expected-error {{deleted}}
|
|
|
|
struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc2 {
|
|
template<typename ...T>
|
|
void *operator new(size_t, T...) {
|
|
using U = void(T...); // expected-note 2{{previous}}
|
|
using U = void; // expected-error {{different types ('void' vs 'void (std::align_val_t)')}} \
|
|
expected-error {{different types ('void' vs 'void (std::align_val_t, Arg)')}}
|
|
}
|
|
};
|
|
auto *waa2 = new WeirdAlignedAlloc2; // expected-note {{instantiation of}}
|
|
auto *waa2p = new (arg) WeirdAlignedAlloc2; // expected-note {{instantiation of}}
|