forked from OSchip/llvm-project
[libcxx] [test] Improve MSVC portability.
test/support/msvc_stdlib_force_include.hpp When testing MSVC's STL with C1XX, simulate a couple more compiler feature-test macros. When testing MSVC's STL, simulate a few library feature-test macros. test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp The vector_size attribute is a non-Standard extension that's supported by Clang and GCC, but not C1XX. Therefore, guard this with `__has_attribute(vector_size)`. Additionally, while these tests pass when MSVC's STL is compiled with Clang, I don't consider this to be a supported scenario for our library, so also guard this with defined(_LIBCPP_VERSION). test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp N4713 23.14.10 [func.not_fn]/1 depicts only `call_wrapper(call_wrapper&&) = default;` and `call_wrapper(const call_wrapper&) = default;`. According to 15.8.2 [class.copy.assign]/2 and /4, this makes call_wrapper non-assignable. Therefore, guard the assignability tests as libc++ specific. Add a (void) cast to tolerate not_fn() being marked as nodiscard. Fixes D41213. llvm-svn: 322144
This commit is contained in:
parent
88e9a15b80
commit
04576cc060
|
@ -89,6 +89,7 @@ int main()
|
|||
CHECK_ALWAYS_LOCK_FREE(float);
|
||||
CHECK_ALWAYS_LOCK_FREE(double);
|
||||
CHECK_ALWAYS_LOCK_FREE(long double);
|
||||
#if __has_attribute(vector_size) && defined(_LIBCPP_VERSION)
|
||||
CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(1 * sizeof(int)))));
|
||||
CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(2 * sizeof(int)))));
|
||||
CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(4 * sizeof(int)))));
|
||||
|
@ -104,6 +105,7 @@ int main()
|
|||
CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(4 * sizeof(double)))));
|
||||
CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(16 * sizeof(double)))));
|
||||
CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(32 * sizeof(double)))));
|
||||
#endif // __has_attribute(vector_size) && defined(_LIBCPP_VERSION)
|
||||
CHECK_ALWAYS_LOCK_FREE(struct Empty {});
|
||||
CHECK_ALWAYS_LOCK_FREE(struct OneInt { int i; });
|
||||
CHECK_ALWAYS_LOCK_FREE(struct IntArr2 { int i[2]; });
|
||||
|
|
|
@ -305,15 +305,17 @@ void constructor_tests()
|
|||
using RetT = decltype(std::not_fn(value));
|
||||
static_assert(std::is_move_constructible<RetT>::value, "");
|
||||
static_assert(std::is_copy_constructible<RetT>::value, "");
|
||||
static_assert(std::is_move_assignable<RetT>::value, "");
|
||||
static_assert(std::is_copy_assignable<RetT>::value, "");
|
||||
LIBCPP_STATIC_ASSERT(std::is_move_assignable<RetT>::value, "");
|
||||
LIBCPP_STATIC_ASSERT(std::is_copy_assignable<RetT>::value, "");
|
||||
auto ret = std::not_fn(value);
|
||||
assert(ret() == false);
|
||||
auto ret2 = std::not_fn(value2);
|
||||
assert(ret2() == true);
|
||||
#if defined(_LIBCPP_VERSION)
|
||||
ret = ret2;
|
||||
assert(ret() == true);
|
||||
assert(ret2() == true);
|
||||
#endif // _LIBCPP_VERSION
|
||||
}
|
||||
{
|
||||
using T = MoveAssignableWrapper;
|
||||
|
@ -322,14 +324,16 @@ void constructor_tests()
|
|||
using RetT = decltype(std::not_fn(std::move(value)));
|
||||
static_assert(std::is_move_constructible<RetT>::value, "");
|
||||
static_assert(!std::is_copy_constructible<RetT>::value, "");
|
||||
static_assert(std::is_move_assignable<RetT>::value, "");
|
||||
LIBCPP_STATIC_ASSERT(std::is_move_assignable<RetT>::value, "");
|
||||
static_assert(!std::is_copy_assignable<RetT>::value, "");
|
||||
auto ret = std::not_fn(std::move(value));
|
||||
assert(ret() == false);
|
||||
auto ret2 = std::not_fn(std::move(value2));
|
||||
assert(ret2() == true);
|
||||
#if defined(_LIBCPP_VERSION)
|
||||
ret = std::move(ret2);
|
||||
assert(ret() == true);
|
||||
#endif // _LIBCPP_VERSION
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,7 +430,7 @@ void throws_in_constructor_test()
|
|||
{
|
||||
ThrowsOnCopy cp;
|
||||
try {
|
||||
std::not_fn(cp);
|
||||
(void)std::not_fn(cp);
|
||||
assert(false);
|
||||
} catch (int const& value) {
|
||||
assert(value == 42);
|
||||
|
|
|
@ -52,6 +52,13 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
|
|||
#define _MSVC_HAS_FEATURE_memory_sanitizer 0
|
||||
#define _MSVC_HAS_FEATURE_thread_sanitizer 0
|
||||
|
||||
#define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X
|
||||
#define _MSVC_HAS_ATTRIBUTE_vector_size 0
|
||||
|
||||
#ifdef _NOEXCEPT_TYPES_SUPPORTED
|
||||
#define __cpp_noexcept_function_type 201510
|
||||
#endif // _NOEXCEPT_TYPES_SUPPORTED
|
||||
|
||||
// Silence compiler warnings.
|
||||
#pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
|
||||
#pragma warning(disable: 4324) // structure was padded due to alignment specifier
|
||||
|
@ -85,4 +92,12 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
|
|||
#define TEST_STD_VER 14
|
||||
#endif // _HAS_CXX17
|
||||
|
||||
// Simulate library feature-test macros.
|
||||
#define __cpp_lib_invoke 201411
|
||||
#define __cpp_lib_void_t 201411
|
||||
|
||||
#if _HAS_CXX17
|
||||
#define __cpp_lib_atomic_is_always_lock_free 201603
|
||||
#endif // _HAS_CXX17
|
||||
|
||||
#endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP
|
||||
|
|
Loading…
Reference in New Issue