From: Ville Voutilainen Date: Tue, 14 Nov 2017 18:11:33 +0000 (+0200) Subject: Implement LWG 2733 and LWG 2759 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13545f19e0e7f1d73ae6c0b39f6b86240de509a8;p=gcc.git Implement LWG 2733 and LWG 2759 * include/experimental/numeric (gcd): Reject cv-qualified bool. (lcm): Likewise. * include/std/numeric (gcd): Likewise. (lcm): Likewise. * testsuite/26_numerics/gcd/gcd_neg.cc: Add tests and adjust. * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise. From-SVN: r254736 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6a7e22b0b1b..dc152b36b5c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2017-11-14 Ville Voutilainen + + Implement LWG 2733 and LWG 2759 + * include/experimental/numeric (gcd): Reject cv-qualified bool. + (lcm): Likewise. + * include/std/numeric (gcd): Likewise. + (lcm): Likewise. + * testsuite/26_numerics/gcd/gcd_neg.cc: Add tests and adjust. + * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise. + 2017-11-14 Jonathan Wakely * include/bits/locale_conv.h (wbuffer_convert::_M_conv_get): Fix typo. diff --git a/libstdc++-v3/include/experimental/numeric b/libstdc++-v3/include/experimental/numeric index c8597fce06d..f037d8e3b3d 100644 --- a/libstdc++-v3/include/experimental/numeric +++ b/libstdc++-v3/include/experimental/numeric @@ -55,10 +55,12 @@ inline namespace fundamentals_v2 constexpr common_type_t<_Mn, _Nn> gcd(_Mn __m, _Nn __n) { - static_assert(is_integral<_Mn>::value, "gcd arguments are integers"); - static_assert(is_integral<_Nn>::value, "gcd arguments are integers"); - static_assert(!is_same<_Mn, bool>::value, "gcd arguments are not bools"); - static_assert(!is_same<_Nn, bool>::value, "gcd arguments are not bools"); + static_assert(is_integral_v<_Mn>, "gcd arguments are integers"); + static_assert(is_integral_v<_Nn>, "gcd arguments are integers"); + static_assert(!is_same_v, bool>, + "gcd arguments are not bools"); + static_assert(!is_same_v, bool>, + "gcd arguments are not bools"); return std::__detail::__gcd(__m, __n); } @@ -67,10 +69,12 @@ inline namespace fundamentals_v2 constexpr common_type_t<_Mn, _Nn> lcm(_Mn __m, _Nn __n) { - static_assert(is_integral<_Mn>::value, "lcm arguments are integers"); - static_assert(is_integral<_Nn>::value, "lcm arguments are integers"); - static_assert(!is_same<_Mn, bool>::value, "lcm arguments are not bools"); - static_assert(!is_same<_Nn, bool>::value, "lcm arguments are not bools"); + static_assert(is_integral_v<_Mn>, "lcm arguments are integers"); + static_assert(is_integral_v<_Nn>, "lcm arguments are integers"); + static_assert(!is_same_v, bool>, + "lcm arguments are not bools"); + static_assert(!is_same_v, bool>, + "lcm arguments are not bools"); return std::__detail::__lcm(__m, __n); } } // namespace fundamentals_v2 diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric index 2b804199c7e..a3a447d798e 100644 --- a/libstdc++-v3/include/std/numeric +++ b/libstdc++-v3/include/std/numeric @@ -131,10 +131,12 @@ namespace __detail constexpr common_type_t<_Mn, _Nn> gcd(_Mn __m, _Nn __n) { - static_assert(is_integral<_Mn>::value, "gcd arguments are integers"); - static_assert(is_integral<_Nn>::value, "gcd arguments are integers"); - static_assert(!is_same<_Mn, bool>::value, "gcd arguments are not bools"); - static_assert(!is_same<_Nn, bool>::value, "gcd arguments are not bools"); + static_assert(is_integral_v<_Mn>, "gcd arguments are integers"); + static_assert(is_integral_v<_Nn>, "gcd arguments are integers"); + static_assert(!is_same_v, bool>, + "gcd arguments are not bools"); + static_assert(!is_same_v, bool>, + "gcd arguments are not bools"); return __detail::__gcd(__m, __n); } @@ -143,10 +145,12 @@ namespace __detail constexpr common_type_t<_Mn, _Nn> lcm(_Mn __m, _Nn __n) { - static_assert(is_integral<_Mn>::value, "lcm arguments are integers"); - static_assert(is_integral<_Nn>::value, "lcm arguments are integers"); - static_assert(!is_same<_Mn, bool>::value, "lcm arguments are not bools"); - static_assert(!is_same<_Nn, bool>::value, "lcm arguments are not bools"); + static_assert(is_integral_v<_Mn>, "lcm arguments are integers"); + static_assert(is_integral_v<_Nn>, "lcm arguments are integers"); + static_assert(!is_same_v, bool>, + "lcm arguments are not bools"); + static_assert(!is_same_v, bool>, + "lcm arguments are not bools"); return __detail::__lcm(__m, __n); } diff --git a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc index 30524a1b06c..63a8afa526f 100644 --- a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc @@ -26,14 +26,29 @@ test01() std::gcd(true, 1); // { dg-error "from here" } std::gcd(1, true); // { dg-error "from here" } std::gcd(true, true); // { dg-error "from here" } + std::gcd(true, 1); // { dg-error "from here" } + std::gcd(1, true); // { dg-error "from here" } + std::gcd(true, true); // { dg-error "from here" } + std::gcd(true, 1); // { dg-error "from here" } + std::gcd(1, true); // { dg-error "from here" } + std::gcd(true, true); // { dg-error "from here" } + std::gcd(true, 1); // { dg-error "from here" } + std::gcd(1, true); // { dg-error "from here" } + std::gcd(true, true); // { dg-error "from here" } + std::gcd(true, 1); // { dg-error "from here" } + std::gcd(1, true); // { dg-error "from here" } + std::gcd(true, true); // { dg-error "from here" } std::gcd(0.1, 1); // { dg-error "from here" } std::gcd(1, 0.1); // { dg-error "from here" } std::gcd(0.1, 0.1); // { dg-error "from here" } + std::gcd(0.1, 0.1); // { dg-error "from here" } } // { dg-error "integers" "" { target *-*-* } 134 } // { dg-error "integers" "" { target *-*-* } 135 } // { dg-error "not bools" "" { target *-*-* } 136 } -// { dg-error "not bools" "" { target *-*-* } 137 } +// { dg-error "not bools" "" { target *-*-* } 138 } // { dg-prune-output "deleted function" } // { dg-prune-output "invalid operands" } diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc index e16e6ae1ee9..d25a92df74d 100644 --- a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc @@ -26,14 +26,29 @@ test01() std::lcm(true, 1); // { dg-error "from here" } std::lcm(1, true); // { dg-error "from here" } std::lcm(true, true); // { dg-error "from here" } + std::lcm(true, 1); // { dg-error "from here" } + std::lcm(1, true); // { dg-error "from here" } + std::lcm(true, true); // { dg-error "from here" } + std::lcm(true, 1); // { dg-error "from here" } + std::lcm(1, true); // { dg-error "from here" } + std::lcm(true, true); // { dg-error "from here" } + std::lcm(true, 1); // { dg-error "from here" } + std::lcm(1, true); // { dg-error "from here" } + std::lcm(true, true); // { dg-error "from here" } + std::lcm(true, 1); // { dg-error "from here" } + std::lcm(1, true); // { dg-error "from here" } + std::lcm(true, true); // { dg-error "from here" } std::lcm(0.1, 1); // { dg-error "from here" } std::lcm(1, 0.1); // { dg-error "from here" } std::lcm(0.1, 0.1); // { dg-error "from here" } + std::lcm(0.1, 0.1); // { dg-error "from here" } } -// { dg-error "integers" "" { target *-*-* } 146 } -// { dg-error "integers" "" { target *-*-* } 147 } -// { dg-error "not bools" "" { target *-*-* } 148 } -// { dg-error "not bools" "" { target *-*-* } 149 } +// { dg-error "integers" "" { target *-*-* } 148 } +// { dg-error "integers" "" { target *-*-* } 149 } +// { dg-error "not bools" "" { target *-*-* } 150 } +// { dg-error "not bools" "" { target *-*-* } 152 } // { dg-prune-output "deleted function" } // { dg-prune-output "invalid operands" }