diff options
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/numeric | 20 | ||||
-rw-r--r-- | libstdc++-v3/include/std/numeric | 20 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc | 17 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc | 23 |
5 files changed, 69 insertions, 21 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6a7e22b..dc152b3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2017-11-14 Ville Voutilainen <ville.voutilainen@gmail.com> + + 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 <jwakely@redhat.com> * 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 c8597fc..f037d8e 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<remove_cv_t<_Mn>, bool>, + "gcd arguments are not bools"); + static_assert(!is_same_v<remove_cv_t<_Nn>, 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<remove_cv_t<_Mn>, bool>, + "lcm arguments are not bools"); + static_assert(!is_same_v<remove_cv_t<_Nn>, 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 2b80419..a3a447d 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<remove_cv_t<_Mn>, bool>, + "gcd arguments are not bools"); + static_assert(!is_same_v<remove_cv<_Nn>, 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<remove_cv_t<_Mn>, bool>, + "lcm arguments are not bools"); + static_assert(!is_same_v<remove_cv_t<_Nn>, 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 30524a1b..63a8afa 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<const bool, int>(true, 1); // { dg-error "from here" } + std::gcd<int, const bool>(1, true); // { dg-error "from here" } + std::gcd<const bool, const bool>(true, true); // { dg-error "from here" } + std::gcd<const bool&, int>(true, 1); // { dg-error "from here" } + std::gcd<int, const bool&>(1, true); // { dg-error "from here" } + std::gcd<const bool&, const bool&>(true, true); // { dg-error "from here" } + std::gcd<const volatile bool, int>(true, 1); // { dg-error "from here" } + std::gcd<int, const volatile bool>(1, true); // { dg-error "from here" } + std::gcd<const volatile bool, + const volatile bool>(true, true); // { dg-error "from here" } + std::gcd<volatile bool, int>(true, 1); // { dg-error "from here" } + std::gcd<int, volatile bool>(1, true); // { dg-error "from here" } + std::gcd<volatile bool, + volatile bool>(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<const int&, const int&>(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 e16e6ae..d25a92d 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<const bool, int>(true, 1); // { dg-error "from here" } + std::lcm<int, const bool>(1, true); // { dg-error "from here" } + std::lcm<const bool, const bool>(true, true); // { dg-error "from here" } + std::lcm<const bool&, int>(true, 1); // { dg-error "from here" } + std::lcm<int, const bool&>(1, true); // { dg-error "from here" } + std::lcm<const bool&, const bool&>(true, true); // { dg-error "from here" } + std::lcm<const volatile bool, int>(true, 1); // { dg-error "from here" } + std::lcm<int, const volatile bool>(1, true); // { dg-error "from here" } + std::lcm<const volatile bool, + const volatile bool>(true, true); // { dg-error "from here" } + std::lcm<volatile bool, int>(true, 1); // { dg-error "from here" } + std::lcm<int, volatile bool>(1, true); // { dg-error "from here" } + std::lcm<volatile bool, + volatile bool>(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<const int&, const int&>(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" } |