PR libstdc++/71187 reimplement declval without add_rvalue_reference
authorJonathan Wakely <jwakely@redhat.com>
Mon, 18 Sep 2017 11:40:10 +0000 (12:40 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 18 Sep 2017 11:40:10 +0000 (12:40 +0100)
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
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc

index 2ec2c06ec1785ebfc7131127eac6673ff069e0d2..9974675aee6de7aa547f631150d996da2aafa182 100644 (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
index f021c42396ccd19b25ae4706ed0dacb822fde5be..15b0d92bcb61197d55766817c31e5ea972b3a024 100644 (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>
+    _Tp
+    __declval(long);
+
   template<typename _Tp>
-    typename add_rvalue_reference<_Tp>::type declval() noexcept;
+    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
index 4e254e8919158b84d41d1ef7fbfb42c82cafebf0..17b41a007db493dc95858844478fe0aa6d152e71 100644 (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>
 
index e3e80f919799e8ff106a8bb92561744b74f5b2d5..308155383f0b4364966b9112b29ffdcd17e9050a 100644 (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 }
index 86b0c2d6da717998c65516d6e39d906b6c05d581..412608e5669d024a38aa85947eecdafedfb88a74 100644 (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 }