Files
TheRock/compiler/amd-llvm/clang/test/Modules/implicit-declared-allocation-functions.cppm
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

65 lines
2.6 KiB
C++
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Tests that the implicit declared allocation functions
// are attached to the global module fragment.
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/foo.cppm -fsyntax-only -verify
// RUN: %clang_cc1 -std=c++20 %t/foo2.cppm -fsyntax-only -verify
//--- foo.cppm
export module foo;
export void alloc_wrapper() {
void *a = ::operator new(32);
// [basic.stc.dynamic.general]Note2
// The implicit declarations do not introduce the names std, std::size_­t,
// std::align_­val_­t, ..., However, referring to std or std::size_­t or
// std::align_­val_­t is ill-formed unless a standard library declaration
// ([cstddef.syn], [new.syn], [std.modules]) of that name precedes
// ([basic.lookup.general]) the use of that name.
void *b = ::operator new((std::size_t)32); // expected-error {{use of undeclared identifier 'std'}}
void *c = ::operator new((std::size_t)32, // expected-error {{use of undeclared identifier 'std'}}
(std::align_val_t)64); // expected-error {{use of undeclared identifier 'std'}}
::operator delete(a);
::operator delete(b, (std::size_t)32); // expected-error {{use of undeclared identifier 'std'}}
::operator delete(c, (std::size_t)32, // expected-error {{use of undeclared identifier 'std'}}
(std::align_val_t)64); // expected-error {{use of undeclared identifier 'std'}}
}
//--- new
namespace std {
using size_t = decltype(sizeof(0));
enum class align_val_t : size_t {};
}
[[nodiscard]] void *operator new(std::size_t);
[[nodiscard]] void *operator new(std::size_t, std::align_val_t);
[[nodiscard]] void *operator new[](std::size_t);
[[nodiscard]] void *operator new[](std::size_t, std::align_val_t);
void operator delete(void*) noexcept;
void operator delete(void*, std::size_t) noexcept;
void operator delete(void*, std::align_val_t) noexcept;
void operator delete(void*, std::size_t, std::align_val_t) noexcept;
void operator delete[](void*, std::size_t, std::align_val_t) noexcept;
void operator delete[](void*, std::size_t) noexcept;
void operator delete[](void*, std::align_val_t) noexcept;
void operator delete[](void*, std::size_t, std::align_val_t) noexcept;
//--- foo2.cppm
// expected-no-diagnostics
module;
#include "new"
export module foo2;
export void alloc_wrapper() {
void *a = ::operator new(32);
void *b = ::operator new((std::size_t)32);
void *c = ::operator new((std::size_t)32,
(std::align_val_t)64);
::operator delete(a);
::operator delete(b, (std::size_t)32);
::operator delete(c, (std::size_t)32,
(std::align_val_t)64);
}