|
| 1 | +// |
| 2 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 3 | +// See https://llvm.org/LICENSE.txt for license information. |
| 4 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | +// |
| 6 | +//===----------------------------------------------------------------------===// |
| 7 | + |
| 8 | +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 |
| 9 | + |
| 10 | +// <mdspan> |
| 11 | + |
| 12 | +// template<class IndexType, size_t... Extents> |
| 13 | +// class extents; |
| 14 | +// |
| 15 | +// Mandates: |
| 16 | +// - IndexType is a signed or unsigned integer type, and |
| 17 | +// - each element of Extents is either equal to dynamic_extent, or is representable as a value of type IndexType. |
| 18 | + |
| 19 | +#include <cstddef> |
| 20 | +#include <climits> |
| 21 | +#include <mdspan> |
| 22 | + |
| 23 | +void invalid_index_types() { |
| 24 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents::index_type must be a signed or unsigned integer type}} |
| 25 | + [[maybe_unused]] std::extents<bool, true> eb; |
| 26 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents::index_type must be a signed or unsigned integer type}} |
| 27 | + [[maybe_unused]] std::extents<char, '*'> ec; |
| 28 | +#ifndef TEST_HAS_NO_CHAR8_T |
| 29 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents::index_type must be a signed or unsigned integer type}} |
| 30 | + [[maybe_unused]] std::extents<char8_t, u8'*'> ec8; |
| 31 | +#endif |
| 32 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents::index_type must be a signed or unsigned integer type}} |
| 33 | + [[maybe_unused]] std::extents<char16_t, u'*'> ec16; |
| 34 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents::index_type must be a signed or unsigned integer type}} |
| 35 | + [[maybe_unused]] std::extents<char32_t, U'*'> ec32; |
| 36 | +#ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 37 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents::index_type must be a signed or unsigned integer type}} |
| 38 | + [[maybe_unused]] std::extents<wchar_t, L'*'> ewc; |
| 39 | +#endif |
| 40 | +} |
| 41 | + |
| 42 | +void invalid_extent_values() { |
| 43 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents ctor: arguments must be representable as index_type and nonnegative}} |
| 44 | + [[maybe_unused]] std::extents<signed char, static_cast<std::size_t>(SCHAR_MAX) + 1> esc1; |
| 45 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents ctor: arguments must be representable as index_type and nonnegative}} |
| 46 | + [[maybe_unused]] std::extents<signed char, std::dynamic_extent - 1> esc2; |
| 47 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents ctor: arguments must be representable as index_type and nonnegative}} |
| 48 | + [[maybe_unused]] std::extents<unsigned char, static_cast<std::size_t>(UCHAR_MAX) + 1> euc1; |
| 49 | + // expected-error-re@*:* {{static assertion failed {{.*}}extents ctor: arguments must be representable as index_type and nonnegative}} |
| 50 | + [[maybe_unused]] std::extents<unsigned char, std::dynamic_extent - 1> euc2; |
| 51 | +} |
0 commit comments