From: Casey Carter Date: Tue, 6 Dec 2016 02:28:19 +0000 (+0000) Subject: std::get<0>([std::variant constant expression]) *is* noexcept. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6da13b6b790750685716134faeb9d6b441972419;p=platform%2Fupstream%2Fllvm.git std::get<0>([std::variant constant expression]) *is* noexcept. Differential review: http://reviews.llvm.org/D27436 llvm-svn: 288760 --- diff --git a/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp b/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp index 669da53..72d17b0 100644 --- a/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp @@ -36,16 +36,35 @@ void test_const_lvalue_get() { { using V = std::variant; constexpr V v(42); - ASSERT_NOT_NOEXCEPT(std::get<0>(v)); +#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 + ASSERT_NOEXCEPT(std::get<0>(v)); +#endif ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); static_assert(std::get<0>(v) == 42, ""); } { using V = std::variant; + const V v(42); + ASSERT_NOT_NOEXCEPT(std::get<0>(v)); + ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); + assert(std::get<0>(v) == 42); + } + { + using V = std::variant; constexpr V v(42l); +#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 + ASSERT_NOEXCEPT(std::get<1>(v)); +#endif ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &); static_assert(std::get<1>(v) == 42, ""); } + { + using V = std::variant; + const V v(42l); + ASSERT_NOT_NOEXCEPT(std::get<1>(v)); + ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &); + assert(std::get<1>(v) == 42); + } // FIXME: Remove these once reference support is reinstated #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { diff --git a/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp index 497f004..fc35537 100644 --- a/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp @@ -30,16 +30,35 @@ void test_const_lvalue_get() { { using V = std::variant; constexpr V v(42); - ASSERT_NOT_NOEXCEPT(std::get(v)); +#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 + ASSERT_NOEXCEPT(std::get(v)); +#endif ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); static_assert(std::get(v) == 42, ""); } { using V = std::variant; + const V v(42); + ASSERT_NOT_NOEXCEPT(std::get(v)); + ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); + assert(std::get(v) == 42); + } + { + using V = std::variant; constexpr V v(42l); +#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 + ASSERT_NOEXCEPT(std::get(v)); +#endif ASSERT_SAME_TYPE(decltype(std::get(v)), const long &); static_assert(std::get(v) == 42, ""); } + { + using V = std::variant; + const V v(42l); + ASSERT_NOT_NOEXCEPT(std::get(v)); + ASSERT_SAME_TYPE(decltype(std::get(v)), const long &); + assert(std::get(v) == 42); + } // FIXME: Remove these once reference support is reinstated #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) {