From: Jonathan Wakely Date: Wed, 17 Apr 2019 19:27:19 +0000 (+0100) Subject: Fix tests for std::variant to match original intention X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d3e662d294a2861a1c8fb9825edd11013d621c1;p=gcc.git Fix tests for std::variant to match original intention * testsuite/20_util/variant/compile.cc (MoveCtorOnly): Fix type to actually match its name. (MoveCtorAndSwapOnly): Define new type that adds swap to MoveCtorOnly. (test_swap()): Fix result for MoveCtorOnly and check MoveCtorAndSwapOnly. From-SVN: r270423 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9ab8bb9154a..8bba4b3d028 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2019-04-17 Jonathan Wakely + * testsuite/20_util/variant/compile.cc (MoveCtorOnly): Fix type to + actually match its name. + (MoveCtorAndSwapOnly): Define new type that adds swap to MoveCtorOnly. + (test_swap()): Fix result for MoveCtorOnly and check + MoveCtorAndSwapOnly. + * include/std/optional (optional::value_or(U&&) &&): Add missing constexpr specifier. * testsuite/20_util/optional/constexpr/observers/4.cc: Check value_or diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index 04fef0be13f..5a2d91709a0 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -54,12 +54,15 @@ struct DefaultNoexcept struct MoveCtorOnly { MoveCtorOnly() noexcept = delete; - MoveCtorOnly(const DefaultNoexcept&) noexcept = delete; - MoveCtorOnly(DefaultNoexcept&&) noexcept { } - MoveCtorOnly& operator=(const DefaultNoexcept&) noexcept = delete; - MoveCtorOnly& operator=(DefaultNoexcept&&) noexcept = delete; + MoveCtorOnly(const MoveCtorOnly&) noexcept = delete; + MoveCtorOnly(MoveCtorOnly&&) noexcept { } + MoveCtorOnly& operator=(const MoveCtorOnly&) noexcept = delete; + MoveCtorOnly& operator=(MoveCtorOnly&&) noexcept = delete; }; +struct MoveCtorAndSwapOnly : MoveCtorOnly { }; +void swap(MoveCtorAndSwapOnly&, MoveCtorAndSwapOnly&) { } + struct nonliteral { nonliteral() { } @@ -259,7 +262,8 @@ 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>, ""); }