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
This commit is contained in:
Jonathan Wakely 2017-09-18 12:40:10 +01:00 committed by Jonathan Wakely
parent ba2c915e3d
commit ec26ff5a01
5 changed files with 30 additions and 11 deletions

View File

@ -1,3 +1,18 @@
2017-09-18 Jonathan Wakely <jwakely@redhat.com>
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 <jakub@redhat.com>
* testsuite/libstdc++-prettyprinters/cxx17.cc: Use -std=c++17 or

View File

@ -754,15 +754,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Destructible and constructible type properties.
template<typename>
struct add_rvalue_reference;
/**
* @brief Utility to simplify expressions used in unevaluated operands
* @ingroup utilities
*/
template<typename _Tp, typename _Up = _Tp&&>
_Up
__declval(int);
template<typename _Tp>
typename add_rvalue_reference<_Tp>::type declval() noexcept;
_Tp
__declval(long);
template<typename _Tp>
auto declval() noexcept -> decltype(__declval<_Tp>(0));
template<typename, unsigned = 0>
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<typename _Tp>
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

View File

@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 2089 }
// { dg-error "static assertion failed" "" { target *-*-* } 2093 }
#include <utility>

View File

@ -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 }

View File

@ -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 }