|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +// UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 10 | + |
| 11 | +// template<size_t N, class T> |
| 12 | +// [[nodiscard]] constexpr T* assume_aligned(T* ptr); |
| 13 | + |
| 14 | +#include <memory> |
| 15 | +#include <cstddef> |
| 16 | + |
| 17 | +template <size_t Size> |
| 18 | +constexpr bool test() { |
| 19 | + char data[1]; |
| 20 | + |
| 21 | + [[maybe_unused]] auto data1 = std::assume_aligned<Size>(data); |
| 22 | + |
| 23 | + return true; |
| 24 | +} |
| 25 | + |
| 26 | +static_assert(test<2>()); |
| 27 | +// expected-error@-1 {{static assertion expression is not an integral constant expression}} |
| 28 | +// expected-note@* {{alignment of the base pointee object (1 byte) is less than the asserted 2 bytes}} |
| 29 | + |
| 30 | +static_assert(test<4>()); |
| 31 | +// expected-error@-1 {{static assertion expression is not an integral constant expression}} |
| 32 | +// expected-note@* {{alignment of the base pointee object (1 byte) is less than the asserted 4 bytes}} |
| 33 | + |
| 34 | +static_assert(test<8>()); |
| 35 | +// expected-error@-1 {{static assertion expression is not an integral constant expression}} |
| 36 | +// expected-note@* {{alignment of the base pointee object (1 byte) is less than the asserted 8 bytes}} |
| 37 | + |
| 38 | +static_assert(test<16>()); |
| 39 | +// expected-error@-1 {{static assertion expression is not an integral constant expression}} |
| 40 | +// expected-note@* {{alignment of the base pointee object (1 byte) is less than the asserted 16 bytes}} |
| 41 | + |
| 42 | +static_assert(test<32>()); |
| 43 | +// expected-error@-1 {{static assertion expression is not an integral constant expression}} |
| 44 | +// expected-note@* {{alignment of the base pointee object (1 byte) is less than the asserted 32 bytes}} |
| 45 | + |
| 46 | +static_assert(test<64>()); |
| 47 | +// expected-error@-1 {{static assertion expression is not an integral constant expression}} |
| 48 | +// expected-note@* {{alignment of the base pointee object (1 byte) is less than the asserted 64 bytes}} |
0 commit comments