From 8c9142276b1f1cbe27bdbd79d79a0d1b9e2b1fb4 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Sun, 31 Jul 2016 17:52:53 +0300 Subject: [PATCH] Add missing variable traits, fix testsuite failures. * include/bits/uses_allocator.h (uses_allocator_v): New. * include/std/functional (is_bind_expression_v, is_placeholder_v): Likewise. * testsuite/20_util/bind/is_placeholder_v.cc: Likewise. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust. * testsuite/20_util/duration/literals/range.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise. * testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc: New. From-SVN: r238921 --- libstdc++-v3/ChangeLog | 19 ++++++++++ libstdc++-v3/include/bits/uses_allocator.h | 4 ++ libstdc++-v3/include/std/functional | 7 ++++ .../20_util/bind/is_placeholder_v.cc | 37 +++++++++++++++++++ .../20_util/declval/requirements/1_neg.cc | 2 +- .../20_util/duration/literals/range.cc | 2 +- .../duration/requirements/typedefs_neg1.cc | 2 +- .../duration/requirements/typedefs_neg2.cc | 2 +- .../duration/requirements/typedefs_neg3.cc | 2 +- .../make_signed/requirements/typedefs_neg.cc | 2 +- .../requirements/typedefs_neg.cc | 4 +- .../ratio/operations/ops_overflow_neg.cc | 2 +- .../requirements/uses_allocator_v.cc | 29 +++++++++++++++ 13 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/bind/is_placeholder_v.cc create mode 100644 libstdc++-v3/testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 08f90de35cd..693aeee66c3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,22 @@ +2016-07-31 Ville Voutilainen + + Add missing variable traits, fix testsuite failures. + * include/bits/uses_allocator.h (uses_allocator_v): New. + * include/std/functional (is_bind_expression_v, is_placeholder_v): + Likewise. + * testsuite/20_util/bind/is_placeholder_v.cc: Likewise. + * testsuite/20_util/declval/requirements/1_neg.cc: Adjust. + * testsuite/20_util/duration/literals/range.cc: Likewise. + * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise. + * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise. + * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + * testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise. + * testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc: + New. + 2016-07-31 Jonathan Wakely * testsuite/18_support/numeric_limits/40856.cc [__STRICT_ANSI__]: Do diff --git a/libstdc++-v3/include/bits/uses_allocator.h b/libstdc++-v3/include/bits/uses_allocator.h index b1ff58a294b..46aea1327a6 100644 --- a/libstdc++-v3/include/bits/uses_allocator.h +++ b/libstdc++-v3/include/bits/uses_allocator.h @@ -108,6 +108,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __ret._M_a = std::__addressof(__a); return __ret; } +#if __cplusplus > 201402L + template + constexpr bool uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; +#endif // C++17 _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 0fdf0436694..97745aeb33b 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -682,6 +682,13 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) : public integral_constant { }; +#if __cplusplus > 201402L + template constexpr bool is_bind_expression_v + = is_bind_expression<_Tp>::value; + template constexpr int is_placeholder_v + = is_placeholder<_Tp>::value; +#endif // C++17 + /** @brief The type of placeholder objects defined by libstdc++. * @ingroup binders */ diff --git a/libstdc++-v3/testsuite/20_util/bind/is_placeholder_v.cc b/libstdc++-v3/testsuite/20_util/bind/is_placeholder_v.cc new file mode 100644 index 00000000000..0499d520591 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/is_placeholder_v.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct X +{ + int operator()() const { return 0; } + int operator()() volatile { return 1; } + int operator()() const volatile { return 2; } + void operator()() { }; +}; + +static_assert( std::is_placeholder::value + == std::is_placeholder_v); + +const auto b0 = std::bind(X()); +static_assert( std::is_bind_expression::value + == std::is_bind_expression_v); + diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index 72246b858ff..558b8c6a2f3 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "static assertion failed" "" { target *-*-* } 2259 } +// { dg-error "static assertion failed" "" { target *-*-* } 2272 } #include diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc index dbb4af199db..6fe4bdea2ab 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc +++ b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc @@ -27,5 +27,5 @@ test01() // std::numeric_limits::max() == 9223372036854775807; auto h = 9223372036854775808h; - // { dg-error "cannot be represented" "" { target *-*-* } 796 } + // { dg-error "cannot be represented" "" { target *-*-* } 800 } } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc index 14814b4d3fd..731a4a7092b 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -31,5 +31,5 @@ void test01() test_type d; } -// { dg-error "rep cannot be a duration" "" { target *-*-* } 246 } +// { dg-error "rep cannot be a duration" "" { target *-*-* } 250 } // { dg-error "required from here" "" { target *-*-* } 31 } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc index a71a8895ab9..c32b8852dfa 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -32,5 +32,5 @@ void test01() test_type d; // { dg-error "required from here" } } -// { dg-error "must be a specialization of ratio" "" { target *-*-* } 247 } +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 251 } // { dg-prune-output "not a member" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc index 016dc81678e..2369440b3d5 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -33,5 +33,5 @@ void test01() test_type d; } -// { dg-error "period must be positive" "" { target *-*-* } 249 } +// { dg-error "period must be positive" "" { target *-*-* } 253 } // { dg-error "required from here" "" { target *-*-* } 33 } diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 772457992ec..5e8fc47b94d 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,4 +48,4 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1924 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1937 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 75fadf40b04..52f89f39e6e 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1820 } -// { dg-error "declaration of" "" { target *-*-* } 1777 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1833 } +// { dg-error "declaration of" "" { target *-*-* } 1790 } diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc index 0efa556ffdf..1a6bc52d7e0 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc @@ -42,7 +42,7 @@ test02() // { dg-error "required from here" "" { target *-*-* } 29 } // { dg-error "expected initializer" "" { target *-*-* } 36 } // { dg-error "expected initializer" "" { target *-*-* } 38 } -// { dg-error "overflow in addition" "" { target *-*-* } 435 } +// { dg-error "overflow in addition" "" { target *-*-* } 451 } // { dg-error "overflow in multiplication" "" { target *-*-* } 97 } // { dg-error "overflow in multiplication" "" { target *-*-* } 99 } // { dg-error "overflow in multiplication" "" { target *-*-* } 101 } diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc new file mode 100644 index 00000000000..cc6e790895f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile } + +// Copyright (C) 2016 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +using namespace std; + +static_assert(uses_allocator>::value + == uses_allocator_v>); +static_assert(uses_allocator>::value + == uses_allocator_v>); -- 2.30.2