From ec26ff5a012428ed864b679c7c171e2e7d917f76 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 18 Sep 2017 12:40:10 +0100 Subject: [PATCH] PR libstdc++/71187 reimplement declval without add_rvalue_reference PR libstdc++/71187 * include/std/type_traits (__declval): New function to deduce return type of declval. (__declval_protector::_delegate): Remove. (declval): Use __declval instead of add_rvalue_reference and __declval_protector::__delegate. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error lineno. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. From-SVN: r252922 --- libstdc++-v3/ChangeLog | 15 ++++++++++++++ libstdc++-v3/include/std/type_traits | 20 +++++++++++-------- .../20_util/declval/requirements/1_neg.cc | 2 +- .../make_signed/requirements/typedefs_neg.cc | 2 +- .../requirements/typedefs_neg.cc | 2 +- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2ec2c06ec17..9974675aee6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,18 @@ +2017-09-18 Jonathan Wakely + + PR libstdc++/71187 + * include/std/type_traits (__declval): New function to deduce return + type of declval. + (__declval_protector::_delegate): Remove. + (declval): Use __declval instead of add_rvalue_reference and + __declval_protector::__delegate. + * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error + lineno. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: + Likewise. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + 2017-09-15 Jakub Jelinek * testsuite/libstdc++-prettyprinters/cxx17.cc: Use -std=c++17 or diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index f021c42396c..15b0d92bcb6 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -754,15 +754,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Destructible and constructible type properties. - template - struct add_rvalue_reference; - /** * @brief Utility to simplify expressions used in unevaluated operands * @ingroup utilities */ + + template + _Up + __declval(int); + + template + _Tp + __declval(long); + template - typename add_rvalue_reference<_Tp>::type declval() noexcept; + auto declval() noexcept -> decltype(__declval<_Tp>(0)); template struct extent; @@ -2079,16 +2085,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __declval_protector { static const bool __stop = false; - static typename add_rvalue_reference<_Tp>::type __delegate(); }; template - inline typename add_rvalue_reference<_Tp>::type - declval() noexcept + auto declval() noexcept -> decltype(__declval<_Tp>(0)) { static_assert(__declval_protector<_Tp>::__stop, "declval() must not be used!"); - return __declval_protector<_Tp>::__delegate(); + return __declval<_Tp>(0); } /// result_of 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 4e254e89191..17b41a007db 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -18,7 +18,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "static assertion failed" "" { target *-*-* } 2089 } +// { dg-error "static assertion failed" "" { target *-*-* } 2093 } #include 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 e3e80f91979..308155383f0 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 @@ -47,4 +47,4 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 39 } // { dg-error "required from here" "" { target *-*-* } 41 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1754 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1760 } 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 86b0c2d6da7..412608e5669 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 @@ -47,5 +47,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 39 } // { dg-error "required from here" "" { target *-*-* } 41 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1650 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1656 } -- 2.30.2