mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-18 05:10:33 +08:00
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
This commit is contained in:
parent
d2e9196e5f
commit
13545f19e0
libstdc++-v3
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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" }
|
||||
|
@ -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" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user