Author: stl_msft Date: Fri Dec 9 13:53:08 2016 New Revision: 289264 URL: http://llvm.org/viewvc/llvm-project?rev=289264&view=rev Log: [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove an unused variable.
test/support/test_macros.h For convenience/greppability, add macros for libcxx-specific static_asserts about noexceptness. (Moving the definitions of ASSERT_NOEXCEPT/ASSERT_NOT_NOEXCEPT isn't technically necessary because they're macros, but I think it's better style to define stuff before using it.) test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp There was a completely unused `TrackedCallable obj;`. apply() isn't depicted with conditional noexcept in C++17. test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp Now that we have LIBCPP_ASSERT_NOEXCEPT, use it. Fixes D27622. Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp libcxx/trunk/test/support/test_macros.h Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp?rev=289264&r1=289263&r2=289264&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp Fri Dec 9 13:53:08 2016 @@ -166,7 +166,6 @@ void check_apply_quals_and_types(Tuple&& void test_call_quals_and_arg_types() { - TrackedCallable obj; using Tup = std::tuple<int, int const&, unsigned&&>; const int x = 42; unsigned y = 101; @@ -199,7 +198,7 @@ void test_noexcept() // test that the functions noexcept-ness is propagated using Tup = std::tuple<int, const char*, long>; Tup t; - ASSERT_NOEXCEPT(std::apply(nec, t)); + LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, t)); ASSERT_NOT_NOEXCEPT(std::apply(tc, t)); } { @@ -207,7 +206,7 @@ void test_noexcept() using Tup = std::tuple<NothrowMoveable, int>; Tup t; ASSERT_NOT_NOEXCEPT(std::apply(nec, t)); - ASSERT_NOEXCEPT(std::apply(nec, std::move(t))); + LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, std::move(t))); } } Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp?rev=289264&r1=289263&r2=289264&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp Fri Dec 9 13:53:08 2016 @@ -175,14 +175,14 @@ void test_noexcept() { Tuple tup; ((void)tup); Tuple const& ctup = tup; ((void)ctup); ASSERT_NOT_NOEXCEPT(std::make_from_tuple<TestType>(ctup)); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup)))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup))); } { using Tuple = std::pair<int, NothrowMoveable>; Tuple tup; ((void)tup); Tuple const& ctup = tup; ((void)ctup); ASSERT_NOT_NOEXCEPT(std::make_from_tuple<TestType>(ctup)); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup)))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup))); } { using Tuple = std::tuple<int, int, int>; @@ -192,7 +192,7 @@ void test_noexcept() { { using Tuple = std::tuple<long, long, long>; Tuple tup; ((void)tup); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup)); } { using Tuple = std::array<int, 3>; @@ -202,7 +202,7 @@ void test_noexcept() { { using Tuple = std::array<long, 3>; Tuple tup; ((void)tup); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup)); } } Modified: libcxx/trunk/test/support/test_macros.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=289264&r1=289263&r2=289264&view=diff ============================================================================== --- libcxx/trunk/test/support/test_macros.h (original) +++ libcxx/trunk/test/support/test_macros.h Fri Dec 9 13:53:08 2016 @@ -128,23 +128,27 @@ #define TEST_NORETURN [[noreturn]] #endif +#define ASSERT_NOEXCEPT(...) \ + static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept") + +#define ASSERT_NOT_NOEXCEPT(...) \ + static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept") + /* Macros for testing libc++ specific behavior and extensions */ #if defined(_LIBCPP_VERSION) #define LIBCPP_ASSERT(...) assert(__VA_ARGS__) #define LIBCPP_STATIC_ASSERT(...) static_assert(__VA_ARGS__) +#define LIBCPP_ASSERT_NOEXCEPT(...) ASSERT_NOEXCEPT(__VA_ARGS__) +#define LIBCPP_ASSERT_NOT_NOEXCEPT(...) ASSERT_NOT_NOEXCEPT(__VA_ARGS__) #define LIBCPP_ONLY(...) __VA_ARGS__ #else #define LIBCPP_ASSERT(...) ((void)0) #define LIBCPP_STATIC_ASSERT(...) ((void)0) +#define LIBCPP_ASSERT_NOEXCEPT(...) ((void)0) +#define LIBCPP_ASSERT_NOT_NOEXCEPT(...) ((void)0) #define LIBCPP_ONLY(...) ((void)0) #endif -#define ASSERT_NOEXCEPT(...) \ - static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept") - -#define ASSERT_NOT_NOEXCEPT(...) \ - static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept") - namespace test_macros_detail { template <class T, class U> struct is_same { enum { value = 0};} ; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits