Add missing variable traits, fix testsuite failures.
authorVille Voutilainen <ville.voutilainen@gmail.com>
Sun, 31 Jul 2016 14:52:53 +0000 (17:52 +0300)
committerVille Voutilainen <ville@gcc.gnu.org>
Sun, 31 Jul 2016 14:52:53 +0000 (17:52 +0300)
* 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

13 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/uses_allocator.h
libstdc++-v3/include/std/functional
libstdc++-v3/testsuite/20_util/bind/is_placeholder_v.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
libstdc++-v3/testsuite/20_util/duration/literals/range.cc
libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc
libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc
libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc
libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc
libstdc++-v3/testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc [new file with mode: 0644]

index 08f90de35cdf444bb5fc2165fd5ee0af7b1d73ec..693aeee66c3f2464f3a80eed1c46848e61bc0868 100644 (file)
@@ -1,3 +1,22 @@
+2016-07-31  Ville Voutilainen  <ville.voutilainen@gmail.com>
+
+       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  <jwakely@redhat.com>
 
        * testsuite/18_support/numeric_limits/40856.cc [__STRICT_ANSI__]: Do
index b1ff58a294b79d717052f7bbe70643c4f95ead4d..46aea1327a689bd4d47d34899465445cef34f272 100644 (file)
@@ -108,6 +108,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __ret._M_a = std::__addressof(__a);
       return __ret;
     }
+#if __cplusplus > 201402L
+  template <typename _Tp, typename _Alloc>
+    constexpr bool uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
+#endif // C++17
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
index 0fdf0436694c476c81687482e4fda48d0b71fb7f..97745aeb33bd3ad3d93a81cc78337588b6ba920b 100644 (file)
@@ -682,6 +682,13 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
     : public integral_constant<int, 0>
     { };
 
+#if __cplusplus > 201402L
+  template <typename _Tp> constexpr bool is_bind_expression_v
+    = is_bind_expression<_Tp>::value;
+  template <typename _Tp> 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 (file)
index 0000000..0499d52
--- /dev/null
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <functional>
+
+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<decltype(std::placeholders::_1)>::value
+              == std::is_placeholder_v<decltype(std::placeholders::_1)>);
+
+const auto b0 = std::bind(X());
+static_assert( std::is_bind_expression<decltype(b0)>::value
+              == std::is_bind_expression_v<decltype(b0)>);
+
index 72246b858ffaa9f1e58323532923802adc740360..558b8c6a2f315b400720c3f5012870533242bd1c 100644 (file)
@@ -19,7 +19,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-error "static assertion failed" "" { target *-*-* } 2259 }
+// { dg-error "static assertion failed" "" { target *-*-* } 2272 }
 
 #include <utility>
 
index dbb4af199db0a315e91c15dbf60fc297468d85be..6fe4bdea2ab18a197a10d93c3d37a0218e55fb6c 100644 (file)
@@ -27,5 +27,5 @@ test01()
 
   // std::numeric_limits<int64_t>::max() == 9223372036854775807;
   auto h = 9223372036854775808h;
-  // { dg-error "cannot be represented" "" { target *-*-* } 796 }
+  // { dg-error "cannot be represented" "" { target *-*-* } 800 }
 }
index 14814b4d3fd21a7b5a1f58772ecef88c8d0c34f4..731a4a7092b19cc3732d667d11e98f722cfa601a 100644 (file)
@@ -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 }
index a71a8895ab9bc552e7e2c27007a0c097b1dbcf2d..c32b8852dfa59285eb7fd58da6ee479ae055a319 100644 (file)
@@ -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" }
index 016dc81678e243d01f5d6e1c7254cab6af020917..2369440b3d50d0748395deda652180b0ed63f730 100644 (file)
@@ -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 }
index 772457992ec5e864c8efd644680a3626388ffd99..5e8fc47b94dd4022879aaa0f1e7f2f6baf32c22f 100644 (file)
@@ -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 }
index 75fadf40b044b90e62a779b80f18236c45fe70b5..52f89f39e6e9df2a23a61464b058f92fbf109763 100644 (file)
@@ -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 }
index 0efa556ffdf2d1b0d21d7f6f2e06d85bdd3f3255..1a6bc52d7e0d7d0db7e15aa36a1344207b1a6ba8 100644 (file)
@@ -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 (file)
index 0000000..cc6e790
--- /dev/null
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <string>
+
+using namespace std;
+
+static_assert(uses_allocator<int, allocator<int>>::value
+             == uses_allocator_v<int, allocator<int>>);
+static_assert(uses_allocator<string, allocator<string>>::value
+             == uses_allocator_v<string, allocator<string>>);