[libcxx] Get is_*_destructible tests passing in C++03.
Summary: This patch adds proper guards to the is_destructible tests depending on the standard version so that they pass in c++03. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10047 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242612 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f339e65df
commit
12c6d9cd93
@ -2917,6 +2917,9 @@ template <class _Tp> struct __libcpp_trivial_destructor
|
|||||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
|
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
|
||||||
: public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
|
: public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
|
||||||
|
|
||||||
|
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
|
||||||
|
: public false_type {};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// is_nothrow_constructible
|
// is_nothrow_constructible
|
||||||
@ -3241,6 +3244,10 @@ template <class _Tp> struct __libcpp_nothrow_destructor
|
|||||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
|
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
|
||||||
: public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
|
: public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
|
||||||
|
|
||||||
|
template <class _Tp>
|
||||||
|
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
|
||||||
|
: public false_type {};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// is_pod
|
// is_pod
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void test_is_destructible()
|
void test_is_destructible()
|
||||||
{
|
{
|
||||||
@ -68,6 +70,7 @@ struct PurePublicDestructor { public: virtual ~PurePublicDestruc
|
|||||||
struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
|
struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
|
||||||
struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
|
struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
|
||||||
|
|
||||||
|
#if TEST_STD_VER >= 11
|
||||||
struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; };
|
struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; };
|
||||||
struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; };
|
struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; };
|
||||||
struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; };
|
struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; };
|
||||||
@ -75,6 +78,7 @@ struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor(
|
|||||||
struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; };
|
struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; };
|
||||||
struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; };
|
struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; };
|
||||||
struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; };
|
struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -99,23 +103,27 @@ int main()
|
|||||||
|
|
||||||
test_is_not_destructible<int[]>();
|
test_is_not_destructible<int[]>();
|
||||||
test_is_not_destructible<void>();
|
test_is_not_destructible<void>();
|
||||||
|
test_is_not_destructible<Function>();
|
||||||
|
|
||||||
|
#if TEST_STD_VER >= 11
|
||||||
|
// Test access controlled destructors
|
||||||
test_is_not_destructible<ProtectedDestructor>();
|
test_is_not_destructible<ProtectedDestructor>();
|
||||||
test_is_not_destructible<PrivateDestructor>();
|
test_is_not_destructible<PrivateDestructor>();
|
||||||
test_is_not_destructible<VirtualProtectedDestructor>();
|
test_is_not_destructible<VirtualProtectedDestructor>();
|
||||||
test_is_not_destructible<VirtualPrivateDestructor>();
|
test_is_not_destructible<VirtualPrivateDestructor>();
|
||||||
test_is_not_destructible<PureProtectedDestructor>();
|
test_is_not_destructible<PureProtectedDestructor>();
|
||||||
test_is_not_destructible<PurePrivateDestructor>();
|
test_is_not_destructible<PurePrivateDestructor>();
|
||||||
|
|
||||||
|
// Test deleted constructors
|
||||||
test_is_not_destructible<DeletedPublicDestructor>();
|
test_is_not_destructible<DeletedPublicDestructor>();
|
||||||
test_is_not_destructible<DeletedProtectedDestructor>();
|
test_is_not_destructible<DeletedProtectedDestructor>();
|
||||||
test_is_not_destructible<DeletedPrivateDestructor>();
|
test_is_not_destructible<DeletedPrivateDestructor>();
|
||||||
|
//test_is_not_destructible<DeletedVirtualPublicDestructor>(); // previously failed due to clang bug #20268
|
||||||
// test_is_not_destructible<DeletedVirtualPublicDestructor>(); // currently fails due to clang bug #20268
|
|
||||||
test_is_not_destructible<DeletedVirtualProtectedDestructor>();
|
test_is_not_destructible<DeletedVirtualProtectedDestructor>();
|
||||||
test_is_not_destructible<DeletedVirtualPrivateDestructor>();
|
test_is_not_destructible<DeletedVirtualPrivateDestructor>();
|
||||||
|
|
||||||
#if __has_feature(cxx_access_control_sfinae)
|
// Test private destructors
|
||||||
test_is_not_destructible<NotEmpty>();
|
test_is_not_destructible<NotEmpty>();
|
||||||
#endif
|
#endif
|
||||||
test_is_not_destructible<Function>();
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void test_is_nothrow_destructible()
|
void test_is_nothrow_destructible()
|
||||||
{
|
{
|
||||||
@ -31,14 +33,23 @@ void test_is_not_nothrow_destructible()
|
|||||||
static_assert(!std::is_nothrow_destructible<const volatile T>::value, "");
|
static_assert(!std::is_nothrow_destructible<const volatile T>::value, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct PublicDestructor { public: ~PublicDestructor() {}};
|
||||||
|
struct ProtectedDestructor { protected: ~ProtectedDestructor() {}};
|
||||||
|
struct PrivateDestructor { private: ~PrivateDestructor() {}};
|
||||||
|
|
||||||
|
struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}};
|
||||||
|
struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}};
|
||||||
|
struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}};
|
||||||
|
|
||||||
|
struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; };
|
||||||
|
struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
|
||||||
|
struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
|
||||||
|
|
||||||
class Empty
|
class Empty
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
class NotEmpty
|
|
||||||
{
|
|
||||||
virtual ~NotEmpty();
|
|
||||||
};
|
|
||||||
|
|
||||||
union Union {};
|
union Union {};
|
||||||
|
|
||||||
@ -52,40 +63,36 @@ class Abstract
|
|||||||
virtual void foo() = 0;
|
virtual void foo() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AbstractDestructor
|
|
||||||
{
|
|
||||||
virtual ~AbstractDestructor() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct A
|
|
||||||
{
|
|
||||||
~A();
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test_is_not_nothrow_destructible<void>();
|
test_is_not_nothrow_destructible<void>();
|
||||||
test_is_not_nothrow_destructible<AbstractDestructor>();
|
|
||||||
test_is_not_nothrow_destructible<NotEmpty>();
|
|
||||||
test_is_not_nothrow_destructible<char[]>();
|
test_is_not_nothrow_destructible<char[]>();
|
||||||
|
test_is_not_nothrow_destructible<char[][3]>();
|
||||||
|
|
||||||
#if __has_feature(cxx_noexcept)
|
|
||||||
test_is_nothrow_destructible<A>();
|
|
||||||
#endif
|
|
||||||
test_is_nothrow_destructible<int&>();
|
test_is_nothrow_destructible<int&>();
|
||||||
#if __has_feature(cxx_unrestricted_unions)
|
|
||||||
test_is_nothrow_destructible<Union>();
|
|
||||||
#endif
|
|
||||||
#if __has_feature(cxx_access_control_sfinae)
|
|
||||||
test_is_nothrow_destructible<Empty>();
|
|
||||||
#endif
|
|
||||||
test_is_nothrow_destructible<int>();
|
test_is_nothrow_destructible<int>();
|
||||||
test_is_nothrow_destructible<double>();
|
test_is_nothrow_destructible<double>();
|
||||||
test_is_nothrow_destructible<int*>();
|
test_is_nothrow_destructible<int*>();
|
||||||
test_is_nothrow_destructible<const int*>();
|
test_is_nothrow_destructible<const int*>();
|
||||||
test_is_nothrow_destructible<char[3]>();
|
test_is_nothrow_destructible<char[3]>();
|
||||||
test_is_nothrow_destructible<Abstract>();
|
|
||||||
#if __has_feature(cxx_noexcept)
|
#if TEST_STD_VER >= 11
|
||||||
|
// requires noexcept. These are all destructible.
|
||||||
|
test_is_nothrow_destructible<PublicDestructor>();
|
||||||
|
test_is_nothrow_destructible<VirtualPublicDestructor>();
|
||||||
|
test_is_nothrow_destructible<PurePublicDestructor>();
|
||||||
test_is_nothrow_destructible<bit_zero>();
|
test_is_nothrow_destructible<bit_zero>();
|
||||||
|
test_is_nothrow_destructible<Abstract>();
|
||||||
|
test_is_nothrow_destructible<Empty>();
|
||||||
|
test_is_nothrow_destructible<Union>();
|
||||||
|
|
||||||
|
// requires access control
|
||||||
|
test_is_not_nothrow_destructible<ProtectedDestructor>();
|
||||||
|
test_is_not_nothrow_destructible<PrivateDestructor>();
|
||||||
|
test_is_not_nothrow_destructible<VirtualProtectedDestructor>();
|
||||||
|
test_is_not_nothrow_destructible<VirtualPrivateDestructor>();
|
||||||
|
test_is_not_nothrow_destructible<PureProtectedDestructor>();
|
||||||
|
test_is_not_nothrow_destructible<PurePrivateDestructor>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void test_is_trivially_destructible()
|
void test_is_trivially_destructible()
|
||||||
{
|
{
|
||||||
@ -31,15 +33,23 @@ void test_is_not_trivially_destructible()
|
|||||||
static_assert(!std::is_trivially_destructible<const volatile T>::value, "");
|
static_assert(!std::is_trivially_destructible<const volatile T>::value, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PublicDestructor { public: ~PublicDestructor() {}};
|
||||||
|
struct ProtectedDestructor { protected: ~ProtectedDestructor() {}};
|
||||||
|
struct PrivateDestructor { private: ~PrivateDestructor() {}};
|
||||||
|
|
||||||
|
struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}};
|
||||||
|
struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}};
|
||||||
|
struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}};
|
||||||
|
|
||||||
|
struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; };
|
||||||
|
struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
|
||||||
|
struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
|
||||||
|
|
||||||
|
|
||||||
class Empty
|
class Empty
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
class NotEmpty
|
|
||||||
{
|
|
||||||
virtual ~NotEmpty();
|
|
||||||
};
|
|
||||||
|
|
||||||
union Union {};
|
union Union {};
|
||||||
|
|
||||||
struct bit_zero
|
struct bit_zero
|
||||||
@ -66,18 +76,28 @@ int main()
|
|||||||
{
|
{
|
||||||
test_is_not_trivially_destructible<void>();
|
test_is_not_trivially_destructible<void>();
|
||||||
test_is_not_trivially_destructible<A>();
|
test_is_not_trivially_destructible<A>();
|
||||||
test_is_not_trivially_destructible<AbstractDestructor>();
|
|
||||||
test_is_not_trivially_destructible<NotEmpty>();
|
|
||||||
test_is_not_trivially_destructible<char[]>();
|
test_is_not_trivially_destructible<char[]>();
|
||||||
|
test_is_not_trivially_destructible<VirtualPublicDestructor>();
|
||||||
|
test_is_not_trivially_destructible<PurePublicDestructor>();
|
||||||
|
|
||||||
test_is_trivially_destructible<Abstract>();
|
test_is_trivially_destructible<Abstract>();
|
||||||
test_is_trivially_destructible<int&>();
|
|
||||||
test_is_trivially_destructible<Union>();
|
test_is_trivially_destructible<Union>();
|
||||||
test_is_trivially_destructible<Empty>();
|
test_is_trivially_destructible<Empty>();
|
||||||
|
test_is_trivially_destructible<int&>();
|
||||||
test_is_trivially_destructible<int>();
|
test_is_trivially_destructible<int>();
|
||||||
test_is_trivially_destructible<double>();
|
test_is_trivially_destructible<double>();
|
||||||
test_is_trivially_destructible<int*>();
|
test_is_trivially_destructible<int*>();
|
||||||
test_is_trivially_destructible<const int*>();
|
test_is_trivially_destructible<const int*>();
|
||||||
test_is_trivially_destructible<char[3]>();
|
test_is_trivially_destructible<char[3]>();
|
||||||
test_is_trivially_destructible<bit_zero>();
|
test_is_trivially_destructible<bit_zero>();
|
||||||
|
|
||||||
|
#if TEST_STD_VER >= 11
|
||||||
|
// requires access control sfinae
|
||||||
|
test_is_not_trivially_destructible<ProtectedDestructor>();
|
||||||
|
test_is_not_trivially_destructible<PrivateDestructor>();
|
||||||
|
test_is_not_trivially_destructible<VirtualProtectedDestructor>();
|
||||||
|
test_is_not_trivially_destructible<VirtualPrivateDestructor>();
|
||||||
|
test_is_not_trivially_destructible<PureProtectedDestructor>();
|
||||||
|
test_is_not_trivially_destructible<PurePrivateDestructor>();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user