[libcxx-commits] [PATCH] D61033: [libc++][test] Fix noexcept assertions in variant's get tests
Casey Carter via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Apr 24 10:13:51 PDT 2019
CaseyCarter updated this revision to Diff 196482.
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.
Use Jonathan's fix, which additionally validates the existence of the bug.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61033/new/
https://reviews.llvm.org/D61033
Files:
test/std/utilities/variant/variant.get/get_index.pass.cpp
test/std/utilities/variant/variant.get/get_type.pass.cpp
test/support/test_workarounds.h
Index: test/support/test_workarounds.h
===================================================================
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -23,4 +23,10 @@
# endif
#endif
+#if defined(TEST_COMPILER_GCC)
+# if __GNUC__ < 9
+# define TEST_WORKAROUND_CONSTEXPR_IMPLIES_NOEXCEPT // GCC PR 87603
+# endif
+#endif
+
#endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/std/utilities/variant/variant.get/get_type.pass.cpp
===================================================================
--- test/std/utilities/variant/variant.get/get_type.pass.cpp
+++ test/std/utilities/variant/variant.get/get_type.pass.cpp
@@ -31,8 +31,10 @@
{
using V = std::variant<int, const long>;
constexpr V v(42);
-#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481
+#ifdef TEST_WORKAROUND_CONSTEXPR_IMPLIES_NOEXCEPT
ASSERT_NOEXCEPT(std::get<int>(v));
+#else
+ ASSERT_NOT_NOEXCEPT(std::get<int>(v));
#endif
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
static_assert(std::get<int>(v) == 42, "");
@@ -47,8 +49,10 @@
{
using V = std::variant<int, const long>;
constexpr V v(42l);
-#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481
+#ifdef TEST_WORKAROUND_CONSTEXPR_IMPLIES_NOEXCEPT
ASSERT_NOEXCEPT(std::get<const long>(v));
+#else
+ ASSERT_NOT_NOEXCEPT(std::get<const long>(v));
#endif
ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &);
static_assert(std::get<const long>(v) == 42, "");
Index: test/std/utilities/variant/variant.get/get_index.pass.cpp
===================================================================
--- test/std/utilities/variant/variant.get/get_index.pass.cpp
+++ test/std/utilities/variant/variant.get/get_index.pass.cpp
@@ -37,8 +37,10 @@
{
using V = std::variant<int, const long>;
constexpr V v(42);
-#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481
+#ifdef TEST_WORKAROUND_CONSTEXPR_IMPLIES_NOEXCEPT
ASSERT_NOEXCEPT(std::get<0>(v));
+#else
+ ASSERT_NOT_NOEXCEPT(std::get<0>(v));
#endif
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
static_assert(std::get<0>(v) == 42, "");
@@ -53,8 +55,10 @@
{
using V = std::variant<int, const long>;
constexpr V v(42l);
-#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481
+#ifdef TEST_WORKAROUND_CONSTEXPR_IMPLIES_NOEXCEPT
ASSERT_NOEXCEPT(std::get<1>(v));
+#else
+ ASSERT_NOT_NOEXCEPT(std::get<1>(v));
#endif
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
static_assert(std::get<1>(v) == 42, "");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61033.196482.patch
Type: text/x-patch
Size: 2632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190424/916fd89a/attachment-0001.bin>
More information about the libcxx-commits
mailing list