mclow.lists created this revision. mclow.lists added a reviewer: EricWF. mclow.lists added a subscriber: cfe-commits.
[[ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190 | N4190 ]] removed `auto_ptr` from C++1z. (and other stuff) Wrap all the auto_ptr bits in an #ifdef so they disappear when compiling with `-std=c++1z` or later. Introduce a new configuration option, `_LIBCPP_NO_REMOVE_AUTOPTR` which allows user code to continue using `auto_ptr` in C++1z mode if desired. Add a test for `_LIBCPP_NO_REMOVE_AUTOPTR`, and mark all the rest of the `auto_ptr` tests to XFAIL for c++1z http://reviews.llvm.org/D20660 Files: include/memory test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
Index: include/memory =================================================================== --- include/memory +++ include/memory @@ -180,10 +180,10 @@ ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x); -template <class Y> struct auto_ptr_ref {}; +template <class Y> struct auto_ptr_ref {}; // removed in C++17 template<class X> -class auto_ptr +class auto_ptr // removed in C++17 { public: typedef X element_type; @@ -242,7 +242,7 @@ template <class U, class E> unique_ptr(unique_ptr<U, E>&& u) noexcept; template <class U> - unique_ptr(auto_ptr<U>&& u) noexcept; + unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17 // destructor ~unique_ptr(); @@ -375,7 +375,7 @@ shared_ptr(shared_ptr&& r) noexcept; template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept; template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); - template<class Y> shared_ptr(auto_ptr<Y>&& r); + template<class Y> shared_ptr(auto_ptr<Y>&& r); // removed in C++17 template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); shared_ptr(nullptr_t) : shared_ptr() { } @@ -387,7 +387,7 @@ template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept; shared_ptr& operator=(shared_ptr&& r) noexcept; template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); - template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); + template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); // removed in C++17 template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); // modifiers: @@ -1959,6 +1959,7 @@ inline _LIBCPP_INLINE_VISIBILITY void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template <class _Tp> struct auto_ptr_ref { @@ -2015,6 +2016,7 @@ public: typedef void element_type; }; +#endif template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, typename remove_cv<_T2>::type>::value, @@ -2639,6 +2641,7 @@ >::type = __nat()) _NOEXCEPT : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template <class _Up> _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, typename enable_if< @@ -2649,6 +2652,7 @@ : __ptr_(__p.release()) { } +#endif _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT { @@ -2700,6 +2704,7 @@ _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template <class _Up> _LIBCPP_INLINE_VISIBILITY typename enable_if< @@ -2709,7 +2714,7 @@ >::type operator=(auto_ptr<_Up> __p) {reset(__p.release()); return *this;} - +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} @@ -3901,6 +3906,7 @@ #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _Yp> shared_ptr(auto_ptr<_Yp>&& __r, @@ -3910,6 +3916,7 @@ shared_ptr(auto_ptr<_Yp> __r, typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); #endif +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>&&, @@ -3973,6 +3980,7 @@ >::type _LIBCPP_INLINE_VISIBILITY operator=(shared_ptr<_Yp>&& __r); +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template<class _Yp> _LIBCPP_INLINE_VISIBILITY typename enable_if @@ -3982,7 +3990,9 @@ shared_ptr >::type& operator=(auto_ptr<_Yp>&& __r); +#endif #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template<class _Yp> _LIBCPP_INLINE_VISIBILITY typename enable_if @@ -3993,6 +4003,7 @@ >::type operator=(auto_ptr<_Yp> __r); #endif +#endif template <class _Yp, class _Dp> typename enable_if < @@ -4327,6 +4338,7 @@ #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template<class _Tp> template<class _Yp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -4342,6 +4354,7 @@ __enable_weak_this(__r.get()); __r.release(); } +#endif template<class _Tp> template <class _Yp, class _Dp> @@ -4648,6 +4661,7 @@ return *this; } +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template<class _Tp> template<class _Yp> inline @@ -4662,6 +4676,7 @@ shared_ptr(_VSTD::move(__r)).swap(*this); return *this; } +#endif template<class _Tp> template <class _Yp, class _Dp> @@ -4680,6 +4695,7 @@ #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_NO_REMOVE_AUTOPTR) template<class _Tp> template<class _Yp> inline _LIBCPP_INLINE_VISIBILITY @@ -4694,6 +4710,7 @@ shared_ptr(__r).swap(*this); return *this; } +#endif template<class _Tp> template <class _Yp, class _Dp> Index: test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp @@ -17,6 +17,8 @@ // ... // }; +// XFAIL: c++1z + #include <memory> #include <type_traits> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp @@ -16,6 +16,8 @@ #include <memory> #include <cassert> +// XFAIL: c++1z + #include "../A.h" void Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp @@ -16,6 +16,8 @@ #include <memory> #include <cassert> +// XFAIL: c++1z + #include "../A.h" void Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp @@ -13,6 +13,8 @@ // X& operator*() const throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp @@ -13,6 +13,8 @@ // X& operator*() const throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> operator auto_ptr_ref<Y>() throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> operator auto_ptr<Y>() throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr_ref<X> r) throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr& operator=(auto_ptr_ref<X> r) throw() +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp @@ -13,6 +13,8 @@ // explicit auto_ptr(X* p =0) throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr& a) throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr& a) throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp =================================================================== --- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp +++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr& operator=(auto_ptr& a) throw(); +// XFAIL: c++1z + #include <memory> #include <cassert> Index: test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp =================================================================== --- test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp +++ test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> +// class auto_ptr; +// +// In C++17, auto_ptr has been removed. +// However, for backwards compatibility, if _LIBCPP_NO_REMOVE_AUTOPTR +// is defined before including <memory>, then auto_ptr will be restored. + +#define _LIBCPP_NO_REMOVE_AUTOPTR + +#include <memory> +#include <type_traits> + +int main() +{ + std::shared_ptr<int> p; +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits