From aa1d62b4af6f1268900981a7f72ca4e9c293f056 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 9 Dec 2016 19:53:08 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289264 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../tuple.tuple/tuple.apply/apply.pass.cpp | 5 ++-- .../tuple.apply/make_from_tuple.pass.cpp | 8 +++--- test/support/test_macros.h | 26 +++++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp index 2e821945d..4c15499f5 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp @@ -166,7 +166,6 @@ void check_apply_quals_and_types(Tuple&& t) { void test_call_quals_and_arg_types() { - TrackedCallable obj; using Tup = std::tuple; 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; 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; 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))); } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp index 9ffd4c159..eee1dd882 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp @@ -175,14 +175,14 @@ void test_noexcept() { Tuple tup; ((void)tup); Tuple const& ctup = tup; ((void)ctup); ASSERT_NOT_NOEXCEPT(std::make_from_tuple(ctup)); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup)))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup))); } { using Tuple = std::pair; Tuple tup; ((void)tup); Tuple const& ctup = tup; ((void)ctup); ASSERT_NOT_NOEXCEPT(std::make_from_tuple(ctup)); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup)))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup))); } { using Tuple = std::tuple; @@ -192,7 +192,7 @@ void test_noexcept() { { using Tuple = std::tuple; Tuple tup; ((void)tup); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(tup))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(tup)); } { using Tuple = std::array; @@ -202,7 +202,7 @@ void test_noexcept() { { using Tuple = std::array; Tuple tup; ((void)tup); - LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(tup))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(tup)); } } diff --git a/test/support/test_macros.h b/test/support/test_macros.h index 4751803e8..32d49be8b 100644 --- a/test/support/test_macros.h +++ b/test/support/test_macros.h @@ -128,23 +128,27 @@ #define TEST_NORETURN [[noreturn]] #endif -/* 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_ONLY(...) __VA_ARGS__ -#else -#define LIBCPP_ASSERT(...) ((void)0) -#define LIBCPP_STATIC_ASSERT(...) ((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") +/* 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 + namespace test_macros_detail { template struct is_same { enum { value = 0};} ;