diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-09-29 22:49:46 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-09-29 22:49:46 +0000 |
commit | bec0fbe74a1a3757ec2693605175a0019c6509b3 (patch) | |
tree | f358197db94c2dddb051fe1ae2d0fc56f0ff1b86 /test/PCH | |
parent | cc732a29ca78bcb7b7c0d4d5ea2699d097740752 (diff) |
P0035R4: add std::align_val_t overloads of operator new/delete in C++17 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282800 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/cxx1z-aligned-alloc.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/PCH/cxx1z-aligned-alloc.cpp b/test/PCH/cxx1z-aligned-alloc.cpp new file mode 100644 index 0000000000..c49b910e85 --- /dev/null +++ b/test/PCH/cxx1z-aligned-alloc.cpp @@ -0,0 +1,35 @@ +// No PCH: +// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include %s -verify %s +// +// With PCH: +// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -emit-pch %s -o %t +// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include-pch %t -verify %s + +// expected-no-diagnostics + +#ifndef HEADER +#define HEADER + +using size_t = decltype(sizeof(0)); + +// Call the overaligned form of 'operator new'. +struct alignas(256) Q { int n; }; +void *f() { return new Q; } + +// Extract the std::align_val_t type from the implicit declaration of operator delete. +template<typename AlignValT> +AlignValT extract(void (*)(void*, size_t, AlignValT)); +using T = decltype(extract(&operator delete)); + +#else + +// ok, calls aligned allocation via placement syntax +void *q = new (T{16}) Q; + +namespace std { + enum class align_val_t : size_t {}; +} + +using T = std::align_val_t; // ok, same type + +#endif |