From: Jonathan Wakely Date: Wed, 17 Apr 2019 19:27:23 +0000 (+0100) Subject: Remove unnecessary string literals from static_assert in C++17 tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=990666d05a36fffbe5414c461025c3c4739333cc;p=gcc.git Remove unnecessary string literals from static_assert in C++17 tests The string literal is optional in C++17 and all these are empty so add no value. * testsuite/20_util/variant/compile.cc: Remove empty string literals from static_assert declarations. From-SVN: r270424 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8bba4b3d028..701e349693c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2019-04-17 Jonathan Wakely + * testsuite/20_util/variant/compile.cc: Remove empty string literals + from static_assert declarations. + * testsuite/20_util/variant/compile.cc (MoveCtorOnly): Fix type to actually match its name. (MoveCtorAndSwapOnly): Define new type that adds swap to MoveCtorOnly. diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index 5a2d91709a0..b67c98adf4a 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -77,59 +77,59 @@ struct nonliteral void default_ctor() { - static_assert(is_default_constructible_v>, ""); - static_assert(is_default_constructible_v>, ""); - static_assert(!is_default_constructible_v>, ""); - static_assert(is_default_constructible_v>, ""); - - static_assert(noexcept(variant()), ""); - static_assert(!noexcept(variant()), ""); - static_assert(noexcept(variant()), ""); + static_assert(is_default_constructible_v>); + static_assert(is_default_constructible_v>); + static_assert(!is_default_constructible_v>); + static_assert(is_default_constructible_v>); + + static_assert(noexcept(variant())); + static_assert(!noexcept(variant())); + static_assert(noexcept(variant())); } void copy_ctor() { - static_assert(is_copy_constructible_v>, ""); - static_assert(!is_copy_constructible_v>, ""); - static_assert(is_trivially_copy_constructible_v>, ""); - static_assert(!is_trivially_copy_constructible_v>, ""); + static_assert(is_copy_constructible_v>); + static_assert(!is_copy_constructible_v>); + static_assert(is_trivially_copy_constructible_v>); + static_assert(!is_trivially_copy_constructible_v>); { variant a; - static_assert(noexcept(variant(a)), ""); + static_assert(noexcept(variant(a))); } { variant a; - static_assert(!noexcept(variant(a)), ""); + static_assert(!noexcept(variant(a))); } { variant a; - static_assert(!noexcept(variant(a)), ""); + static_assert(!noexcept(variant(a))); } { variant a; - static_assert(noexcept(variant(a)), ""); + static_assert(noexcept(variant(a))); } } void move_ctor() { - static_assert(is_move_constructible_v>, ""); - static_assert(!is_move_constructible_v>, ""); - static_assert(is_trivially_move_constructible_v>, ""); - static_assert(!is_trivially_move_constructible_v>, ""); - static_assert(!noexcept(variant(declval>())), ""); - static_assert(noexcept(variant(declval>())), ""); + static_assert(is_move_constructible_v>); + static_assert(!is_move_constructible_v>); + static_assert(is_trivially_move_constructible_v>); + static_assert(!is_trivially_move_constructible_v>); + static_assert(!noexcept(variant(declval>()))); + static_assert(noexcept(variant(declval>()))); } void arbitrary_ctor() { - static_assert(!is_constructible_v, const char*>, ""); - static_assert(is_constructible_v, const char*>, ""); - static_assert(noexcept(variant(int{})), ""); - static_assert(noexcept(variant(int{})), ""); - static_assert(!noexcept(variant(Empty{})), ""); - static_assert(noexcept(variant(DefaultNoexcept{})), ""); + static_assert(!is_constructible_v, const char*>); + static_assert(is_constructible_v, const char*>); + static_assert(noexcept(variant(int{}))); + static_assert(noexcept(variant(int{}))); + static_assert(!noexcept(variant(Empty{}))); + static_assert(noexcept(variant(DefaultNoexcept{}))); } void in_place_index_ctor() @@ -142,105 +142,105 @@ void in_place_type_ctor() { variant a(in_place_type, "a"); variant b(in_place_type, {'a'}); - static_assert(!is_constructible_v, in_place_type_t, const char*>, ""); + static_assert(!is_constructible_v, in_place_type_t, const char*>); } void dtor() { - static_assert(is_destructible_v>, ""); - static_assert(is_destructible_v>, ""); + static_assert(is_destructible_v>); + static_assert(is_destructible_v>); } void copy_assign() { - static_assert(is_copy_assignable_v>, ""); - static_assert(!is_copy_assignable_v>, ""); - static_assert(is_trivially_copy_assignable_v>, ""); - static_assert(!is_trivially_copy_assignable_v>, ""); + static_assert(is_copy_assignable_v>); + static_assert(!is_copy_assignable_v>); + static_assert(is_trivially_copy_assignable_v>); + static_assert(!is_trivially_copy_assignable_v>); { variant a; - static_assert(!noexcept(a = a), ""); + static_assert(!noexcept(a = a)); } { variant a; - static_assert(noexcept(a = a), ""); + static_assert(noexcept(a = a)); } } void move_assign() { - static_assert(is_move_assignable_v>, ""); - static_assert(!is_move_assignable_v>, ""); - static_assert(is_trivially_move_assignable_v>, ""); - static_assert(!is_trivially_move_assignable_v>, ""); + static_assert(is_move_assignable_v>); + static_assert(!is_move_assignable_v>); + static_assert(is_trivially_move_assignable_v>); + static_assert(!is_trivially_move_assignable_v>); { variant a; - static_assert(!noexcept(a = std::move(a)), ""); + static_assert(!noexcept(a = std::move(a))); } { variant a; - static_assert(noexcept(a = std::move(a)), ""); + static_assert(noexcept(a = std::move(a))); } } void arbitrary_assign() { - static_assert(!is_assignable_v, const char*>, ""); - static_assert(is_assignable_v, const char*>, ""); - static_assert(noexcept(variant() = int{}), ""); - static_assert(noexcept(variant() = int{}), ""); - static_assert(!noexcept(variant() = Empty{}), ""); - static_assert(noexcept(variant() = DefaultNoexcept{}), ""); + static_assert(!is_assignable_v, const char*>); + static_assert(is_assignable_v, const char*>); + static_assert(noexcept(variant() = int{})); + static_assert(noexcept(variant() = int{})); + static_assert(!noexcept(variant() = Empty{})); + static_assert(noexcept(variant() = DefaultNoexcept{})); } void test_get() { - static_assert(is_same(variant())), int&&>::value, ""); - static_assert(is_same(variant())), string&&>::value, ""); - static_assert(is_same(variant())), const string&&>::value, ""); + static_assert(is_same(variant())), int&&>::value); + static_assert(is_same(variant())), string&&>::value); + static_assert(is_same(variant())), const string&&>::value); - static_assert(is_same(variant())), int&&>::value, ""); - static_assert(is_same(variant())), string&&>::value, ""); - static_assert(is_same(variant())), const string&&>::value, ""); + static_assert(is_same(variant())), int&&>::value); + static_assert(is_same(variant())), string&&>::value); + static_assert(is_same(variant())), const string&&>::value); } void test_relational() { { constexpr variant a(42), b(43); - static_assert((a < b), ""); - static_assert(!(a > b), ""); - static_assert((a <= b), ""); - static_assert(!(a == b), ""); - static_assert((a != b), ""); - static_assert(!(a >= b), ""); + static_assert((a < b)); + static_assert(!(a > b)); + static_assert((a <= b)); + static_assert(!(a == b)); + static_assert((a != b)); + static_assert(!(a >= b)); } { constexpr variant a(42), b(42); - static_assert(!(a < b), ""); - static_assert(!(a > b), ""); - static_assert((a <= b), ""); - static_assert((a == b), ""); - static_assert(!(a != b), ""); - static_assert((a >= b), ""); + static_assert(!(a < b)); + static_assert(!(a > b)); + static_assert((a <= b)); + static_assert((a == b)); + static_assert(!(a != b)); + static_assert((a >= b)); } { constexpr variant a(43), b(42); - static_assert(!(a < b), ""); - static_assert((a > b), ""); - static_assert(!(a <= b), ""); - static_assert(!(a == b), ""); - static_assert((a != b), ""); - static_assert((a >= b), ""); + static_assert(!(a < b)); + static_assert((a > b)); + static_assert(!(a <= b)); + static_assert(!(a == b)); + static_assert((a != b)); + static_assert((a >= b)); } { constexpr monostate a, b; - static_assert(!(a < b), ""); - static_assert(!(a > b), ""); - static_assert((a <= b), ""); - static_assert((a == b), ""); - static_assert(!(a != b), ""); - static_assert((a >= b), ""); + static_assert(!(a < b)); + static_assert(!(a > b)); + static_assert((a <= b)); + static_assert((a == b)); + static_assert(!(a != b)); + static_assert((a >= b)); } } @@ -261,10 +261,10 @@ static_assert( !std::is_swappable_v> ); void test_swap() { - static_assert(is_swappable_v>, ""); - static_assert(!is_swappable_v>, ""); - static_assert(is_swappable_v>, ""); - static_assert(!is_swappable_v>, ""); + static_assert(is_swappable_v>); + static_assert(!is_swappable_v>); + static_assert(is_swappable_v>); + static_assert(!is_swappable_v>); } void test_visit() @@ -297,7 +297,7 @@ void test_visit() constexpr bool operator()(const int&) { return true; } constexpr bool operator()(const nonliteral&) { return false; } }; - static_assert(visit(Visitor(), variant(0)), ""); + static_assert(visit(Visitor(), variant(0))); } { struct Visitor @@ -305,7 +305,7 @@ void test_visit() constexpr bool operator()(const int&) { return true; } constexpr bool operator()(const nonliteral&) { return false; } }; - static_assert(visit(Visitor(), variant(0)), ""); + static_assert(visit(Visitor(), variant(0))); } // PR libstdc++/79513 { @@ -318,17 +318,17 @@ void test_visit() void test_constexpr() { constexpr variant a; - static_assert(holds_alternative(a), ""); + static_assert(holds_alternative(a)); constexpr variant b(in_place_index<0>, int{}); - static_assert(holds_alternative(b), ""); + static_assert(holds_alternative(b)); constexpr variant c(in_place_type, int{}); - static_assert(holds_alternative(c), ""); + static_assert(holds_alternative(c)); constexpr variant d(in_place_index<1>, char{}); - static_assert(holds_alternative(d), ""); + static_assert(holds_alternative(d)); constexpr variant e(in_place_type, char{}); - static_assert(holds_alternative(e), ""); + static_assert(holds_alternative(e)); constexpr variant f(char{}); - static_assert(holds_alternative(f), ""); + static_assert(holds_alternative(f)); { struct literal { @@ -342,51 +342,51 @@ void test_constexpr() { constexpr variant a(42); - static_assert(get<0>(a) == 42, ""); + static_assert(get<0>(a) == 42); } { constexpr variant a(42); - static_assert(get<0>(a) == 42, ""); + static_assert(get<0>(a) == 42); } { constexpr variant a(42); - static_assert(get<1>(a) == 42, ""); + static_assert(get<1>(a) == 42); } { constexpr variant a(42); - static_assert(get(a) == 42, ""); + static_assert(get(a) == 42); } { constexpr variant a(42); - static_assert(get(a) == 42, ""); + static_assert(get(a) == 42); } { constexpr variant a(42); - static_assert(get(a) == 42, ""); + static_assert(get(a) == 42); } { constexpr variant a(42); - static_assert(get<0>(std::move(a)) == 42, ""); + static_assert(get<0>(std::move(a)) == 42); } { constexpr variant a(42); - static_assert(get<0>(std::move(a)) == 42, ""); + static_assert(get<0>(std::move(a)) == 42); } { constexpr variant a(42); - static_assert(get<1>(std::move(a)) == 42, ""); + static_assert(get<1>(std::move(a)) == 42); } { constexpr variant a(42); - static_assert(get(std::move(a)) == 42, ""); + static_assert(get(std::move(a)) == 42); } { constexpr variant a(42); - static_assert(get(std::move(a)) == 42, ""); + static_assert(get(std::move(a)) == 42); } { constexpr variant a(42); - static_assert(get(std::move(a)) == 42, ""); + static_assert(get(std::move(a)) == 42); } } @@ -434,12 +434,12 @@ void test_adl() void test_variant_alternative() { - static_assert(is_same_v>, int>, ""); - static_assert(is_same_v>, string>, ""); + static_assert(is_same_v>, int>); + static_assert(is_same_v>, string>); - static_assert(is_same_v>, const int>, ""); - static_assert(is_same_v>, volatile int>, ""); - static_assert(is_same_v>, const volatile int>, ""); + static_assert(is_same_v>, const int>); + static_assert(is_same_v>, volatile int>); + static_assert(is_same_v>, const volatile int>); } template @@ -460,11 +460,11 @@ template void test_emplace() { - static_assert(has_type_emplace, int>(0), ""); - static_assert(!has_type_emplace, int>(0), ""); - static_assert(has_index_emplace, 0>(0), ""); - static_assert(!has_type_emplace, AllDeleted>(0), ""); - static_assert(!has_index_emplace, 0>(0), ""); + static_assert(has_type_emplace, int>(0)); + static_assert(!has_type_emplace, int>(0)); + static_assert(has_index_emplace, 0>(0)); + static_assert(!has_type_emplace, AllDeleted>(0)); + static_assert(!has_index_emplace, 0>(0)); } void test_triviality() @@ -479,10 +479,10 @@ void test_triviality() A& operator=(const A&) CA; \ A& operator=(A&&) MA; \ }; \ - static_assert(CC_VAL == is_trivially_copy_constructible_v>, ""); \ - static_assert(MC_VAL == is_trivially_move_constructible_v>, ""); \ - static_assert(CA_VAL == is_trivially_copy_assignable_v>, ""); \ - static_assert(MA_VAL == is_trivially_move_assignable_v>, ""); \ + static_assert(CC_VAL == is_trivially_copy_constructible_v>); \ + static_assert(MC_VAL == is_trivially_move_constructible_v>); \ + static_assert(CA_VAL == is_trivially_copy_assignable_v>); \ + static_assert(MA_VAL == is_trivially_move_assignable_v>); \ } TEST_TEMPLATE(=default, =default, =default, =default, =default, true, true, true, true) TEST_TEMPLATE(=default, =default, =default, =default, , true, true, true, false) @@ -527,10 +527,10 @@ void test_triviality() A& operator=(const A&) CA; \ A& operator=(A&&) MA; \ }; \ - static_assert(!is_trivially_copy_constructible_v>, ""); \ - static_assert(!is_trivially_move_constructible_v>, ""); \ - static_assert(!is_trivially_copy_assignable_v>, ""); \ - static_assert(!is_trivially_move_assignable_v>, ""); \ + static_assert(!is_trivially_copy_constructible_v>); \ + static_assert(!is_trivially_move_constructible_v>); \ + static_assert(!is_trivially_copy_assignable_v>); \ + static_assert(!is_trivially_move_assignable_v>); \ } TEST_TEMPLATE(=default, =default, =default, =default) TEST_TEMPLATE(=default, =default, =default, ) @@ -550,8 +550,8 @@ void test_triviality() TEST_TEMPLATE( , , , ) #undef TEST_TEMPLATE - static_assert(is_trivially_copy_constructible_v>, ""); - static_assert(is_trivially_move_constructible_v>, ""); - static_assert(is_trivially_copy_assignable_v>, ""); - static_assert(is_trivially_move_assignable_v>, ""); + static_assert(is_trivially_copy_constructible_v>); + static_assert(is_trivially_move_constructible_v>); + static_assert(is_trivially_copy_assignable_v>); + static_assert(is_trivially_move_assignable_v>); }