| 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 | // <bitset> |
| 10 | |
| 11 | // This test ensures that we don't use a non-uglified name 'base', 'iterator', |
| 12 | // 'const_iterator', and `const_reference` in the implementation of bitset. |
| 13 | // |
| 14 | // See https://github.com/llvm/llvm-project/issues/111125. |
| 15 | // See https://github.com/llvm/llvm-project/issues/121618. |
| 16 | |
| 17 | // XFAIL: FROZEN-CXX03-HEADERS-FIXME |
| 18 | |
| 19 | #include <cstddef> |
| 20 | #include <bitset> |
| 21 | #include <type_traits> |
| 22 | |
| 23 | struct my_base { |
| 24 | typedef int* iterator; |
| 25 | typedef const int* const_iterator; |
| 26 | typedef my_base base; |
| 27 | typedef const int& const_reference; |
| 28 | typedef std::ptrdiff_t difference_type; |
| 29 | typedef std::size_t size_type; |
| 30 | }; |
| 31 | |
| 32 | template <std::size_t N> |
| 33 | struct my_derived : my_base, std::bitset<N> {}; |
| 34 | |
| 35 | static_assert(std::is_same<my_derived<0>::iterator, int*>::value, "" ); |
| 36 | static_assert(std::is_same<my_derived<1>::iterator, int*>::value, "" ); |
| 37 | static_assert(std::is_same<my_derived<8>::iterator, int*>::value, "" ); |
| 38 | static_assert(std::is_same<my_derived<12>::iterator, int*>::value, "" ); |
| 39 | static_assert(std::is_same<my_derived<16>::iterator, int*>::value, "" ); |
| 40 | static_assert(std::is_same<my_derived<32>::iterator, int*>::value, "" ); |
| 41 | static_assert(std::is_same<my_derived<48>::iterator, int*>::value, "" ); |
| 42 | static_assert(std::is_same<my_derived<64>::iterator, int*>::value, "" ); |
| 43 | static_assert(std::is_same<my_derived<96>::iterator, int*>::value, "" ); |
| 44 | |
| 45 | static_assert(std::is_same<my_derived<0>::const_iterator, const int*>::value, "" ); |
| 46 | static_assert(std::is_same<my_derived<1>::const_iterator, const int*>::value, "" ); |
| 47 | static_assert(std::is_same<my_derived<8>::const_iterator, const int*>::value, "" ); |
| 48 | static_assert(std::is_same<my_derived<12>::const_iterator, const int*>::value, "" ); |
| 49 | static_assert(std::is_same<my_derived<16>::const_iterator, const int*>::value, "" ); |
| 50 | static_assert(std::is_same<my_derived<32>::const_iterator, const int*>::value, "" ); |
| 51 | static_assert(std::is_same<my_derived<48>::const_iterator, const int*>::value, "" ); |
| 52 | static_assert(std::is_same<my_derived<64>::const_iterator, const int*>::value, "" ); |
| 53 | static_assert(std::is_same<my_derived<96>::const_iterator, const int*>::value, "" ); |
| 54 | |
| 55 | static_assert(std::is_same<my_derived<0>::base, my_base>::value, "" ); |
| 56 | static_assert(std::is_same<my_derived<1>::base, my_base>::value, "" ); |
| 57 | static_assert(std::is_same<my_derived<8>::base, my_base>::value, "" ); |
| 58 | static_assert(std::is_same<my_derived<12>::base, my_base>::value, "" ); |
| 59 | static_assert(std::is_same<my_derived<16>::base, my_base>::value, "" ); |
| 60 | static_assert(std::is_same<my_derived<32>::base, my_base>::value, "" ); |
| 61 | static_assert(std::is_same<my_derived<48>::base, my_base>::value, "" ); |
| 62 | static_assert(std::is_same<my_derived<64>::base, my_base>::value, "" ); |
| 63 | static_assert(std::is_same<my_derived<96>::base, my_base>::value, "" ); |
| 64 | |
| 65 | static_assert(std::is_same<my_derived<0>::const_reference, const int&>::value, "" ); |
| 66 | static_assert(std::is_same<my_derived<1>::const_reference, const int&>::value, "" ); |
| 67 | static_assert(std::is_same<my_derived<8>::const_reference, const int&>::value, "" ); |
| 68 | static_assert(std::is_same<my_derived<12>::const_reference, const int&>::value, "" ); |
| 69 | static_assert(std::is_same<my_derived<16>::const_reference, const int&>::value, "" ); |
| 70 | static_assert(std::is_same<my_derived<32>::const_reference, const int&>::value, "" ); |
| 71 | static_assert(std::is_same<my_derived<48>::const_reference, const int&>::value, "" ); |
| 72 | static_assert(std::is_same<my_derived<64>::const_reference, const int&>::value, "" ); |
| 73 | static_assert(std::is_same<my_derived<96>::const_reference, const int&>::value, "" ); |
| 74 | |
| 75 | static_assert(std::is_same<my_derived<0>::difference_type, std::ptrdiff_t>::value, "" ); |
| 76 | static_assert(std::is_same<my_derived<1>::difference_type, std::ptrdiff_t>::value, "" ); |
| 77 | static_assert(std::is_same<my_derived<8>::difference_type, std::ptrdiff_t>::value, "" ); |
| 78 | static_assert(std::is_same<my_derived<12>::difference_type, std::ptrdiff_t>::value, "" ); |
| 79 | static_assert(std::is_same<my_derived<16>::difference_type, std::ptrdiff_t>::value, "" ); |
| 80 | static_assert(std::is_same<my_derived<32>::difference_type, std::ptrdiff_t>::value, "" ); |
| 81 | static_assert(std::is_same<my_derived<48>::difference_type, std::ptrdiff_t>::value, "" ); |
| 82 | static_assert(std::is_same<my_derived<64>::difference_type, std::ptrdiff_t>::value, "" ); |
| 83 | static_assert(std::is_same<my_derived<96>::difference_type, std::ptrdiff_t>::value, "" ); |
| 84 | |
| 85 | static_assert(std::is_same<my_derived<0>::size_type, std::size_t>::value, "" ); |
| 86 | static_assert(std::is_same<my_derived<1>::size_type, std::size_t>::value, "" ); |
| 87 | static_assert(std::is_same<my_derived<8>::size_type, std::size_t>::value, "" ); |
| 88 | static_assert(std::is_same<my_derived<12>::size_type, std::size_t>::value, "" ); |
| 89 | static_assert(std::is_same<my_derived<16>::size_type, std::size_t>::value, "" ); |
| 90 | static_assert(std::is_same<my_derived<32>::size_type, std::size_t>::value, "" ); |
| 91 | static_assert(std::is_same<my_derived<48>::size_type, std::size_t>::value, "" ); |
| 92 | static_assert(std::is_same<my_derived<64>::size_type, std::size_t>::value, "" ); |
| 93 | static_assert(std::is_same<my_derived<96>::size_type, std::size_t>::value, "" ); |
| 94 | |