Commit ec26ff5a by Jonathan Wakely Committed by Jonathan Wakely

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
parent ba2c915e
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> 2017-09-15 Jakub Jelinek <jakub@redhat.com>
* testsuite/libstdc++-prettyprinters/cxx17.cc: Use -std=c++17 or * testsuite/libstdc++-prettyprinters/cxx17.cc: Use -std=c++17 or
......
...@@ -754,15 +754,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -754,15 +754,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Destructible and constructible type properties. // Destructible and constructible type properties.
template<typename>
struct add_rvalue_reference;
/** /**
* @brief Utility to simplify expressions used in unevaluated operands * @brief Utility to simplify expressions used in unevaluated operands
* @ingroup utilities * @ingroup utilities
*/ */
template<typename _Tp, typename _Up = _Tp&&>
_Up
__declval(int);
template<typename _Tp>
_Tp
__declval(long);
template<typename _Tp> template<typename _Tp>
typename add_rvalue_reference<_Tp>::type declval() noexcept; auto declval() noexcept -> decltype(__declval<_Tp>(0));
template<typename, unsigned = 0> template<typename, unsigned = 0>
struct extent; struct extent;
...@@ -2079,16 +2085,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2079,16 +2085,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __declval_protector struct __declval_protector
{ {
static const bool __stop = false; static const bool __stop = false;
static typename add_rvalue_reference<_Tp>::type __delegate();
}; };
template<typename _Tp> template<typename _Tp>
inline typename add_rvalue_reference<_Tp>::type auto declval() noexcept -> decltype(__declval<_Tp>(0))
declval() noexcept
{ {
static_assert(__declval_protector<_Tp>::__stop, static_assert(__declval_protector<_Tp>::__stop,
"declval() must not be used!"); "declval() must not be used!");
return __declval_protector<_Tp>::__delegate(); return __declval<_Tp>(0);
} }
/// result_of /// result_of
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 2089 } // { dg-error "static assertion failed" "" { target *-*-* } 2093 }
#include <utility> #include <utility>
......
...@@ -47,4 +47,4 @@ void test01() ...@@ -47,4 +47,4 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 39 } // { dg-error "required from here" "" { target *-*-* } 39 }
// { dg-error "required from here" "" { target *-*-* } 41 } // { 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 }
...@@ -47,5 +47,5 @@ void test01() ...@@ -47,5 +47,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 39 } // { dg-error "required from here" "" { target *-*-* } 39 }
// { dg-error "required from here" "" { target *-*-* } 41 } // { 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 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment