From: Jonathan Wakely Date: Mon, 22 Jul 2019 16:57:40 +0000 (+0100) Subject: Rename testsuite directory to match P0553R4 stable names X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ac8e32236d0fe6c07545ab0e275403af4a63710;p=gcc.git Rename testsuite directory to match P0553R4 stable names * testsuite/26_numerics/bit/bitops.count/*: Rename to ... * testsuite/26_numerics/bit/bit.count/*: Here. From-SVN: r273707 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6c6e41db802..099314d7e85 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2019-07-22 Jonathan Wakely + * testsuite/26_numerics/bit/bitops.count/*: Rename to ... + * testsuite/26_numerics/bit/bit.count/*: Here. + * include/std/bit (__rotl, __rotr): Change second parameter from unsigned int to int and handle negative values. (rotl, rotr): Remove check for __STRICT_ANSI__. Change second diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countl_one.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countl_one.cc new file mode 100644 index 00000000000..50b681c0090 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countl_one.cc @@ -0,0 +1,94 @@ +// Copyright (C) 2018-2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +template +constexpr auto +test(UInt x) +-> decltype(std::countl_one(x)) +{ + static_assert( noexcept(std::countl_one(x)) ); + + constexpr unsigned digits = std::numeric_limits::digits; + + static_assert( std::countl_one((UInt)0) == 0 ); + static_assert( std::countl_one((UInt)-1) == digits ); + + static_assert( std::countl_one((UInt)3) == 0 ); + static_assert( std::countl_one((UInt)((UInt)1 << digits - 1)) == 1 ); + static_assert( std::countl_one((UInt)((UInt)3 << digits - 2)) == 2 ); + static_assert( std::countl_one((UInt)((UInt)7 << digits - 3)) == 3 ); + static_assert( std::countl_one((UInt)((UInt)255 << digits - 8)) == 8 ); + + if constexpr (std::numeric_limits::digits > 8) + { + static_assert( std::countl_one((UInt)((UInt)-1 ^ 0x100)) == digits - 9 ); + static_assert( std::countl_one((UInt)((UInt)-1 ^ 0x101)) == digits - 9 ); + static_assert( std::countl_one((UInt)((UInt)-1 ^ 0x201)) == digits - 10 ); + } + + if constexpr (std::numeric_limits::digits > 64) + { + static_assert( std::countl_one((UInt)-1 ^ ((UInt)1 << 70)) == digits - 71 ); + } + + return true; +} + +static_assert( test( (unsigned char)0 ) ); +static_assert( test( (unsigned short)0 ) ); +static_assert( test( (unsigned int)0 ) ); +static_assert( test( (unsigned long)0 ) ); +static_assert( test( (unsigned long long)0 ) ); + +// std::countl_one(T) shall not participate in overload resolution +// unless T is an unsigned integer type. +struct X { constexpr bool did_not_match() { return true; } }; +constexpr X test(...) { return X{}; } +static_assert( test( (bool)0 ).did_not_match() ); +static_assert( test( (char)0 ).did_not_match() ); +static_assert( test( (int)0 ).did_not_match() ); +static_assert( test( (char16_t)0 ).did_not_match() ); +static_assert( test( (float)0 ).did_not_match() ); +static_assert( test( (void*)0 ).did_not_match() ); +static_assert( test( X{} ).did_not_match() ); +enum E : unsigned { e }; +static_assert( test( e ).did_not_match() ); + +#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 +static_assert( test( (unsigned __int128)0 ) ); +static_assert( test( (__int128)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_0) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); +#endif + +#include +static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countl_zero.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countl_zero.cc new file mode 100644 index 00000000000..8c8a13fed34 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countl_zero.cc @@ -0,0 +1,91 @@ +// Copyright (C) 2018-2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +template +constexpr auto +test(UInt x) +-> decltype(std::countl_zero(x)) +{ + static_assert( noexcept(std::countl_zero(x)) ); + + constexpr unsigned digits = std::numeric_limits::digits; + + static_assert( std::countl_zero((UInt)0) == digits ); + static_assert( std::countl_zero((UInt)-1) == 0 ); + + static_assert( std::countl_zero((UInt)1) == digits - 1 ); + static_assert( std::countl_zero((UInt)3) == digits - 2 ); + static_assert( std::countl_zero((UInt)0b0101'1010) == digits - 7 ); + + if constexpr (std::numeric_limits::digits > 8) + { + static_assert( std::countl_zero((UInt)(1u << 8)) == digits - 9 ); + static_assert( std::countl_zero((UInt)(3u << 9)) == digits - 11 ); + } + + if constexpr (std::numeric_limits::digits > 64) + { + static_assert( std::countl_zero((UInt)3 << 70) == digits - 72 ); + } + + return true; +} + +static_assert( test( (unsigned char)0 ) ); +static_assert( test( (unsigned short)0 ) ); +static_assert( test( (unsigned int)0 ) ); +static_assert( test( (unsigned long)0 ) ); +static_assert( test( (unsigned long long)0 ) ); + +// std::countl_zero(T) shall not participate in overload resolution +// unless T is an unsigned integer type. +struct X { constexpr bool did_not_match() { return true; } }; +constexpr X test(...) { return X{}; } +static_assert( test( (bool)0 ).did_not_match() ); +static_assert( test( (char)0 ).did_not_match() ); +static_assert( test( (int)0 ).did_not_match() ); +static_assert( test( (char16_t)0 ).did_not_match() ); +static_assert( test( (float)0 ).did_not_match() ); +static_assert( test( (void*)0 ).did_not_match() ); +static_assert( test( X{} ).did_not_match() ); +enum E : unsigned { e }; +static_assert( test( e ).did_not_match() ); + +#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 +static_assert( test( (unsigned __int128)0 ) ); +static_assert( test( (__int128)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_0) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); +#endif + +#include +static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countr_one.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countr_one.cc new file mode 100644 index 00000000000..16c98579316 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countr_one.cc @@ -0,0 +1,93 @@ +// Copyright (C) 2018-2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +template +constexpr auto +test(UInt x) +-> decltype(std::countr_one(x)) +{ + static_assert( noexcept(std::countr_one(x)) ); + + constexpr unsigned digits = std::numeric_limits::digits; + + static_assert( std::countr_one((UInt)0) == 0 ); + static_assert( std::countr_one((UInt)-1) == digits ); + static_assert( std::countr_one((UInt)127) == 7 ); + + static_assert( std::countr_one((UInt)1) == 1 ); + static_assert( std::countr_one((UInt)3) == 2 ); + static_assert( std::countr_one((UInt)0x1f) == 5 ); + static_assert( std::countr_one((UInt)((UInt)-1 ^ 0x10)) == 4 ); + + if constexpr (std::numeric_limits::digits > 8) + { + static_assert( std::countr_one((UInt)((UInt)-1 ^ 0x100)) == 8 ); + static_assert( std::countr_one((UInt)((UInt)-1 ^ 0x101)) == 0 ); + } + + if constexpr (std::numeric_limits::digits > 64) + { + static_assert( std::countr_one((UInt)-1 ^ ((UInt)1 << 70)) == 70 ); + } + + return true; +} + +static_assert( test( (unsigned char)0 ) ); +static_assert( test( (unsigned short)0 ) ); +static_assert( test( (unsigned int)0 ) ); +static_assert( test( (unsigned long)0 ) ); +static_assert( test( (unsigned long long)0 ) ); + +// std::countr_one(T) shall not participate in overload resolution +// unless T is an unsigned integer type. +struct X { constexpr bool did_not_match() { return true; } }; +constexpr X test(...) { return X{}; } +static_assert( test( (bool)0 ).did_not_match() ); +static_assert( test( (char)0 ).did_not_match() ); +static_assert( test( (int)0 ).did_not_match() ); +static_assert( test( (char16_t)0 ).did_not_match() ); +static_assert( test( (float)0 ).did_not_match() ); +static_assert( test( (void*)0 ).did_not_match() ); +static_assert( test( X{} ).did_not_match() ); +enum E : unsigned { e }; +static_assert( test( e ).did_not_match() ); + +#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 +static_assert( test( (unsigned __int128)0 ) ); +static_assert( test( (__int128)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_0) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); +#endif + +#include +static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countr_zero.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countr_zero.cc new file mode 100644 index 00000000000..0e1970b2af6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/countr_zero.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2018-2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +template +constexpr auto +test(UInt x) +-> decltype(std::countr_zero(x)) +{ + static_assert( noexcept(std::countr_zero(x)) ); + + constexpr unsigned digits = std::numeric_limits::digits; + + static_assert( std::countr_zero((UInt)0) == digits ); + static_assert( std::countr_zero((UInt)-1) == 0 ); + static_assert( std::countr_zero((UInt)127) == 0 ); + + static_assert( std::countr_zero((UInt)1) == 0 ); + static_assert( std::countr_zero((UInt)2) == 1 ); + static_assert( std::countr_zero((UInt)0x70) == 4 ); + + if constexpr (std::numeric_limits::digits > 8) + { + static_assert( std::countr_zero((UInt)(1u << 8)) == 8 ); + static_assert( std::countr_zero((UInt)(4u << 9)) == 11 ); + } + + if constexpr (std::numeric_limits::digits > 64) + { + static_assert( std::countr_zero((UInt)2 << 70) == 71 ); + } + + return true; +} + +static_assert( test( (unsigned char)0 ) ); +static_assert( test( (unsigned short)0 ) ); +static_assert( test( (unsigned int)0 ) ); +static_assert( test( (unsigned long)0 ) ); +static_assert( test( (unsigned long long)0 ) ); + +// std::countr_zero(T) shall not participate in overload resolution +// unless T is an unsigned integer type. +struct X { constexpr bool did_not_match() { return true; } }; +constexpr X test(...) { return X{}; } +static_assert( test( (bool)0 ).did_not_match() ); +static_assert( test( (char)0 ).did_not_match() ); +static_assert( test( (int)0 ).did_not_match() ); +static_assert( test( (char16_t)0 ).did_not_match() ); +static_assert( test( (float)0 ).did_not_match() ); +static_assert( test( (void*)0 ).did_not_match() ); +static_assert( test( X{} ).did_not_match() ); +enum E : unsigned { e }; +static_assert( test( e ).did_not_match() ); + +#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 +static_assert( test( (unsigned __int128)0 ) ); +static_assert( test( (__int128)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_0) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); +#endif + +#include +static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.count/popcount.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/popcount.cc new file mode 100644 index 00000000000..07b8c6ac4e2 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.count/popcount.cc @@ -0,0 +1,95 @@ +// Copyright (C) 2018-2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +template +constexpr auto +test(UInt x) +-> decltype(std::popcount(x)) +{ + static_assert( noexcept(std::popcount(x)) ); + + constexpr unsigned digits = std::numeric_limits::digits; + + static_assert( std::popcount((UInt)0) == 0 ); + static_assert( std::popcount((UInt)-1) == digits ); + static_assert( std::popcount((UInt)-2) == digits - 1 ); + static_assert( std::popcount((UInt)127) == 7 ); + + static_assert( std::popcount((UInt)1) == 1 ); + static_assert( std::popcount((UInt)2) == 1 ); + static_assert( std::popcount((UInt)0x70) == 3 ); + + if constexpr (std::numeric_limits::digits > 8) + { + static_assert( std::popcount((UInt)(0x101)) == 2 ); + static_assert( std::popcount((UInt)(0xfff)) == 12 ); + } + + if constexpr (std::numeric_limits::digits > 64) + { + static_assert( std::popcount((UInt)0xffffffffffffffff) == 64 ); + static_assert( std::popcount(0x5555555555555555 | ((UInt)1 << 64)) == 33 ); + static_assert( std::popcount(0x5555555555555555 | ((UInt)3 << 64)) == 34 ); + } + + return true; +} + +static_assert( test( (unsigned char)0 ) ); +static_assert( test( (unsigned short)0 ) ); +static_assert( test( (unsigned int)0 ) ); +static_assert( test( (unsigned long)0 ) ); +static_assert( test( (unsigned long long)0 ) ); + +// std::popcount(T) shall not participate in overload resolution +// unless T is an unsigned integer type. +struct X { constexpr bool did_not_match() { return true; } }; +constexpr X test(...) { return X{}; } +static_assert( test( (bool)0 ).did_not_match() ); +static_assert( test( (char)0 ).did_not_match() ); +static_assert( test( (int)0 ).did_not_match() ); +static_assert( test( (char16_t)0 ).did_not_match() ); +static_assert( test( (float)0 ).did_not_match() ); +static_assert( test( (void*)0 ).did_not_match() ); +static_assert( test( X{} ).did_not_match() ); +enum E : unsigned { e }; +static_assert( test( e ).did_not_match() ); + +#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 +static_assert( test( (unsigned __int128)0 ) ); +static_assert( test( (__int128)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_0) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) +static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); +static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); +#endif + +#include +static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc deleted file mode 100644 index 50b681c0090..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2018-2019 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++2a" } -// { dg-do compile { target c++2a } } - -#include - -template -constexpr auto -test(UInt x) --> decltype(std::countl_one(x)) -{ - static_assert( noexcept(std::countl_one(x)) ); - - constexpr unsigned digits = std::numeric_limits::digits; - - static_assert( std::countl_one((UInt)0) == 0 ); - static_assert( std::countl_one((UInt)-1) == digits ); - - static_assert( std::countl_one((UInt)3) == 0 ); - static_assert( std::countl_one((UInt)((UInt)1 << digits - 1)) == 1 ); - static_assert( std::countl_one((UInt)((UInt)3 << digits - 2)) == 2 ); - static_assert( std::countl_one((UInt)((UInt)7 << digits - 3)) == 3 ); - static_assert( std::countl_one((UInt)((UInt)255 << digits - 8)) == 8 ); - - if constexpr (std::numeric_limits::digits > 8) - { - static_assert( std::countl_one((UInt)((UInt)-1 ^ 0x100)) == digits - 9 ); - static_assert( std::countl_one((UInt)((UInt)-1 ^ 0x101)) == digits - 9 ); - static_assert( std::countl_one((UInt)((UInt)-1 ^ 0x201)) == digits - 10 ); - } - - if constexpr (std::numeric_limits::digits > 64) - { - static_assert( std::countl_one((UInt)-1 ^ ((UInt)1 << 70)) == digits - 71 ); - } - - return true; -} - -static_assert( test( (unsigned char)0 ) ); -static_assert( test( (unsigned short)0 ) ); -static_assert( test( (unsigned int)0 ) ); -static_assert( test( (unsigned long)0 ) ); -static_assert( test( (unsigned long long)0 ) ); - -// std::countl_one(T) shall not participate in overload resolution -// unless T is an unsigned integer type. -struct X { constexpr bool did_not_match() { return true; } }; -constexpr X test(...) { return X{}; } -static_assert( test( (bool)0 ).did_not_match() ); -static_assert( test( (char)0 ).did_not_match() ); -static_assert( test( (int)0 ).did_not_match() ); -static_assert( test( (char16_t)0 ).did_not_match() ); -static_assert( test( (float)0 ).did_not_match() ); -static_assert( test( (void*)0 ).did_not_match() ); -static_assert( test( X{} ).did_not_match() ); -enum E : unsigned { e }; -static_assert( test( e ).did_not_match() ); - -#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 -static_assert( test( (unsigned __int128)0 ) ); -static_assert( test( (__int128)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_0) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_1) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_2) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); -#endif - -#include -static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc deleted file mode 100644 index 8c8a13fed34..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2018-2019 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++2a" } -// { dg-do compile { target c++2a } } - -#include - -template -constexpr auto -test(UInt x) --> decltype(std::countl_zero(x)) -{ - static_assert( noexcept(std::countl_zero(x)) ); - - constexpr unsigned digits = std::numeric_limits::digits; - - static_assert( std::countl_zero((UInt)0) == digits ); - static_assert( std::countl_zero((UInt)-1) == 0 ); - - static_assert( std::countl_zero((UInt)1) == digits - 1 ); - static_assert( std::countl_zero((UInt)3) == digits - 2 ); - static_assert( std::countl_zero((UInt)0b0101'1010) == digits - 7 ); - - if constexpr (std::numeric_limits::digits > 8) - { - static_assert( std::countl_zero((UInt)(1u << 8)) == digits - 9 ); - static_assert( std::countl_zero((UInt)(3u << 9)) == digits - 11 ); - } - - if constexpr (std::numeric_limits::digits > 64) - { - static_assert( std::countl_zero((UInt)3 << 70) == digits - 72 ); - } - - return true; -} - -static_assert( test( (unsigned char)0 ) ); -static_assert( test( (unsigned short)0 ) ); -static_assert( test( (unsigned int)0 ) ); -static_assert( test( (unsigned long)0 ) ); -static_assert( test( (unsigned long long)0 ) ); - -// std::countl_zero(T) shall not participate in overload resolution -// unless T is an unsigned integer type. -struct X { constexpr bool did_not_match() { return true; } }; -constexpr X test(...) { return X{}; } -static_assert( test( (bool)0 ).did_not_match() ); -static_assert( test( (char)0 ).did_not_match() ); -static_assert( test( (int)0 ).did_not_match() ); -static_assert( test( (char16_t)0 ).did_not_match() ); -static_assert( test( (float)0 ).did_not_match() ); -static_assert( test( (void*)0 ).did_not_match() ); -static_assert( test( X{} ).did_not_match() ); -enum E : unsigned { e }; -static_assert( test( e ).did_not_match() ); - -#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 -static_assert( test( (unsigned __int128)0 ) ); -static_assert( test( (__int128)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_0) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_1) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_2) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); -#endif - -#include -static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc deleted file mode 100644 index 16c98579316..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2018-2019 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++2a" } -// { dg-do compile { target c++2a } } - -#include - -template -constexpr auto -test(UInt x) --> decltype(std::countr_one(x)) -{ - static_assert( noexcept(std::countr_one(x)) ); - - constexpr unsigned digits = std::numeric_limits::digits; - - static_assert( std::countr_one((UInt)0) == 0 ); - static_assert( std::countr_one((UInt)-1) == digits ); - static_assert( std::countr_one((UInt)127) == 7 ); - - static_assert( std::countr_one((UInt)1) == 1 ); - static_assert( std::countr_one((UInt)3) == 2 ); - static_assert( std::countr_one((UInt)0x1f) == 5 ); - static_assert( std::countr_one((UInt)((UInt)-1 ^ 0x10)) == 4 ); - - if constexpr (std::numeric_limits::digits > 8) - { - static_assert( std::countr_one((UInt)((UInt)-1 ^ 0x100)) == 8 ); - static_assert( std::countr_one((UInt)((UInt)-1 ^ 0x101)) == 0 ); - } - - if constexpr (std::numeric_limits::digits > 64) - { - static_assert( std::countr_one((UInt)-1 ^ ((UInt)1 << 70)) == 70 ); - } - - return true; -} - -static_assert( test( (unsigned char)0 ) ); -static_assert( test( (unsigned short)0 ) ); -static_assert( test( (unsigned int)0 ) ); -static_assert( test( (unsigned long)0 ) ); -static_assert( test( (unsigned long long)0 ) ); - -// std::countr_one(T) shall not participate in overload resolution -// unless T is an unsigned integer type. -struct X { constexpr bool did_not_match() { return true; } }; -constexpr X test(...) { return X{}; } -static_assert( test( (bool)0 ).did_not_match() ); -static_assert( test( (char)0 ).did_not_match() ); -static_assert( test( (int)0 ).did_not_match() ); -static_assert( test( (char16_t)0 ).did_not_match() ); -static_assert( test( (float)0 ).did_not_match() ); -static_assert( test( (void*)0 ).did_not_match() ); -static_assert( test( X{} ).did_not_match() ); -enum E : unsigned { e }; -static_assert( test( e ).did_not_match() ); - -#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 -static_assert( test( (unsigned __int128)0 ) ); -static_assert( test( (__int128)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_0) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_1) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_2) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); -#endif - -#include -static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc deleted file mode 100644 index 0e1970b2af6..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2018-2019 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++2a" } -// { dg-do compile { target c++2a } } - -#include - -template -constexpr auto -test(UInt x) --> decltype(std::countr_zero(x)) -{ - static_assert( noexcept(std::countr_zero(x)) ); - - constexpr unsigned digits = std::numeric_limits::digits; - - static_assert( std::countr_zero((UInt)0) == digits ); - static_assert( std::countr_zero((UInt)-1) == 0 ); - static_assert( std::countr_zero((UInt)127) == 0 ); - - static_assert( std::countr_zero((UInt)1) == 0 ); - static_assert( std::countr_zero((UInt)2) == 1 ); - static_assert( std::countr_zero((UInt)0x70) == 4 ); - - if constexpr (std::numeric_limits::digits > 8) - { - static_assert( std::countr_zero((UInt)(1u << 8)) == 8 ); - static_assert( std::countr_zero((UInt)(4u << 9)) == 11 ); - } - - if constexpr (std::numeric_limits::digits > 64) - { - static_assert( std::countr_zero((UInt)2 << 70) == 71 ); - } - - return true; -} - -static_assert( test( (unsigned char)0 ) ); -static_assert( test( (unsigned short)0 ) ); -static_assert( test( (unsigned int)0 ) ); -static_assert( test( (unsigned long)0 ) ); -static_assert( test( (unsigned long long)0 ) ); - -// std::countr_zero(T) shall not participate in overload resolution -// unless T is an unsigned integer type. -struct X { constexpr bool did_not_match() { return true; } }; -constexpr X test(...) { return X{}; } -static_assert( test( (bool)0 ).did_not_match() ); -static_assert( test( (char)0 ).did_not_match() ); -static_assert( test( (int)0 ).did_not_match() ); -static_assert( test( (char16_t)0 ).did_not_match() ); -static_assert( test( (float)0 ).did_not_match() ); -static_assert( test( (void*)0 ).did_not_match() ); -static_assert( test( X{} ).did_not_match() ); -enum E : unsigned { e }; -static_assert( test( e ).did_not_match() ); - -#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 -static_assert( test( (unsigned __int128)0 ) ); -static_assert( test( (__int128)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_0) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_1) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_2) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); -#endif - -#include -static_assert( test( (std::byte)0 ).did_not_match() ); diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc deleted file mode 100644 index 07b8c6ac4e2..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2018-2019 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++2a" } -// { dg-do compile { target c++2a } } - -#include - -template -constexpr auto -test(UInt x) --> decltype(std::popcount(x)) -{ - static_assert( noexcept(std::popcount(x)) ); - - constexpr unsigned digits = std::numeric_limits::digits; - - static_assert( std::popcount((UInt)0) == 0 ); - static_assert( std::popcount((UInt)-1) == digits ); - static_assert( std::popcount((UInt)-2) == digits - 1 ); - static_assert( std::popcount((UInt)127) == 7 ); - - static_assert( std::popcount((UInt)1) == 1 ); - static_assert( std::popcount((UInt)2) == 1 ); - static_assert( std::popcount((UInt)0x70) == 3 ); - - if constexpr (std::numeric_limits::digits > 8) - { - static_assert( std::popcount((UInt)(0x101)) == 2 ); - static_assert( std::popcount((UInt)(0xfff)) == 12 ); - } - - if constexpr (std::numeric_limits::digits > 64) - { - static_assert( std::popcount((UInt)0xffffffffffffffff) == 64 ); - static_assert( std::popcount(0x5555555555555555 | ((UInt)1 << 64)) == 33 ); - static_assert( std::popcount(0x5555555555555555 | ((UInt)3 << 64)) == 34 ); - } - - return true; -} - -static_assert( test( (unsigned char)0 ) ); -static_assert( test( (unsigned short)0 ) ); -static_assert( test( (unsigned int)0 ) ); -static_assert( test( (unsigned long)0 ) ); -static_assert( test( (unsigned long long)0 ) ); - -// std::popcount(T) shall not participate in overload resolution -// unless T is an unsigned integer type. -struct X { constexpr bool did_not_match() { return true; } }; -constexpr X test(...) { return X{}; } -static_assert( test( (bool)0 ).did_not_match() ); -static_assert( test( (char)0 ).did_not_match() ); -static_assert( test( (int)0 ).did_not_match() ); -static_assert( test( (char16_t)0 ).did_not_match() ); -static_assert( test( (float)0 ).did_not_match() ); -static_assert( test( (void*)0 ).did_not_match() ); -static_assert( test( X{} ).did_not_match() ); -enum E : unsigned { e }; -static_assert( test( e ).did_not_match() ); - -#if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128 -static_assert( test( (unsigned __int128)0 ) ); -static_assert( test( (__int128)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_0) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_0)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_0)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_1) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_1)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() ); -#endif -#if defined(__GLIBCXX_TYPE_INT_N_2) -static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) ); -static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() ); -#endif - -#include -static_assert( test( (std::byte)0 ).did_not_match() );