From: Jonathan Wakely Date: Fri, 17 May 2019 14:13:43 +0000 (+0100) Subject: Fix std::variant test for ILP32 targets X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac781bc88019eae2bb119d550f587ff4c9ff174d;p=gcc.git Fix std::variant test for ILP32 targets * testsuite/20_util/variant/compile.cc: Fix narrowing test for ILP32 targets. Add more cases from P0608R3. * testsuite/20_util/variant/run.cc: Add more cases from P0608R3. From-SVN: r271325 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 397b8edd327..1ba66d80a15 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2019-05-17 Jonathan Wakely + * testsuite/20_util/variant/compile.cc: Fix narrowing test for ILP32 + targets. Add more cases from P0608R3. + * testsuite/20_util/variant/run.cc: Add more cases from P0608R3. + * include/bits/random.h (seed_seq::param): Fix non-reserved name. * include/experimental/type_traits (is_detected_exact) (is_detected_exact_v): Likewise. diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index 4560f774452..dc3d4c2b3f1 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -144,7 +144,15 @@ void arbitrary_ctor() static_assert(noexcept(variant(DefaultNoexcept{}))); // P0608R3 disallow narrowing conversions and boolean conversions - static_assert(!is_constructible_v, long>); + static_assert(!is_constructible_v, int>); + static_assert(!is_constructible_v>, int>); + static_assert(is_constructible_v, char>); + static_assert(!is_constructible_v, int>); + static_assert(is_constructible_v, int>); + struct big_int { big_int(int) { } }; + static_assert(is_constructible_v, int>); + + static_assert(!is_constructible_v, unsigned>); static_assert(!is_constructible_v, int>); static_assert(!is_constructible_v, void*>); } diff --git a/libstdc++-v3/testsuite/20_util/variant/run.cc b/libstdc++-v3/testsuite/20_util/variant/run.cc index ac60ccbc13e..045e1f23ada 100644 --- a/libstdc++-v3/testsuite/20_util/variant/run.cc +++ b/libstdc++-v3/testsuite/20_util/variant/run.cc @@ -128,6 +128,17 @@ void arbitrary_ctor() VERIFY(y.index() == 1); VERIFY(std::get<1>(y).d == d); } + + { + // P0608R3 + variant v1 = 'a'; + VERIFY(std::get<1>(v1) == int('a')); + variant v2 = 0; + VERIFY(std::get<1>(v2) == 0L); + struct big_int { big_int(int) { } }; + variant v3 = 0; + VERIFY(v3.index() == 1); + } } struct ThrowingMoveCtorThrowsCopyCtor