aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/bits/shared_ptr.h11
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h11
-rw-r--r--libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc6
4 files changed, 27 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index b124d75..bf22550 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
2016-08-04 Jonathan Wakely <jwakely@redhat.com>
+ * testsuite/20_util/enable_shared_from_this/members/reinit.cc: Use
+ effective target not dg-options. Move check for feature-test macro to:
+ * testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
+ New test.
+
* include/std/functional (_Unwrap): Rename to __inv_unwrap.
(__invfwd): Adjust.
(__invoke_impl): Remove unused template parameters.
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index 483c2bc..747b09a 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -586,6 +586,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
shared_from_this() const
{ return shared_ptr<const _Tp>(this->_M_weak_this); }
+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
+#define __cpp_lib_enable_shared_from_this 201603
+ weak_ptr<_Tp>
+ weak_from_this()
+ { return this->_M_weak_this; }
+
+ weak_ptr<const _Tp>
+ weak_from_this() const
+ { return this->_M_weak_this; }
+#endif
+
private:
template<typename _Tp1>
void
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 2698ba4..787dc9b 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -1472,7 +1472,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept
{
-#define __cpp_lib_enable_shared_from_this 201603
if (use_count() == 0)
{
_M_ptr = __ptr;
@@ -1557,6 +1556,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
shared_from_this() const
{ return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
+ __weak_ptr<_Tp, _Lp>
+ weak_from_this()
+ { return this->_M_weak_this; }
+
+ __weak_ptr<const _Tp, _Lp>
+ weak_from_this() const
+ { return this->_M_weak_this; }
+#endif
+
private:
template<typename _Tp1>
void
diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc
index 1cf9148..3209f87 100644
--- a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc
+++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc
@@ -15,15 +15,11 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-std=gnu++11" }
+// { dg-do run { target c++11 } }
#include <memory>
#include <testsuite_hooks.h>
-#if __cpp_lib_enable_shared_from_this < 201603
-# error "__cpp_lib_enable_shared_from_this < 201603"
-#endif
-
struct X : public std::enable_shared_from_this<X> { };
bool