1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
12 // constexpr T bit_ceil(T x) noexcept;
14 // Remarks: This function shall not participate in overload resolution unless
15 // T is an unsigned integer type
24 enum E1
: unsigned char { rEd
};
25 enum class E2
: unsigned char { red
};
28 constexpr bool toobig()
30 return 0 == std::bit_ceil(std::numeric_limits
<T
>::max());
35 // Make sure we generate a compile-time error for UB
36 static_assert(toobig
<unsigned char>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
37 static_assert(toobig
<unsigned short>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
38 static_assert(toobig
<unsigned>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
39 static_assert(toobig
<unsigned long>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
40 static_assert(toobig
<unsigned long long>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
42 static_assert(toobig
<std::uint8_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
43 static_assert(toobig
<std::uint16_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
44 static_assert(toobig
<std::uint32_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
45 static_assert(toobig
<std::uint64_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
46 static_assert(toobig
<std::size_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
47 static_assert(toobig
<std::uintmax_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
48 static_assert(toobig
<std::uintptr_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}