[libcxx-commits] [libcxx] [libc++][test] Mark `optional` test functions as `TEST_CONSTEXPR_CXX20` (PR #94172)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 2 14:16:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Stephan T. Lavavej (StephanTLavavej)
<details>
<summary>Changes</summary>
[P2231R1](https://wg21.link/P2231R1) "Missing `constexpr` in `std::optional` and `std::variant`" was accepted as a C++20 Defect Report, not a C++17 Defect Report. Accordingly, `test_empty_emplace()` and `check_reset()` should be marked as `TEST_CONSTEXPR_CXX20`. Note that their `static_assert`s are properly guarded:
https://github.com/llvm/llvm-project/blob/4ce65423be0ba1d90c11b6a79981d6314e1cf36d/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp#L270-L272
https://github.com/llvm/llvm-project/blob/4ce65423be0ba1d90c11b6a79981d6314e1cf36d/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp#L53-L55
Found while running libc++'s tests with MSVC's STL, as we activate our `constexpr` here for C++20 and above.
---
Full diff: https://github.com/llvm/llvm-project/pull/94172.diff
2 Files Affected:
- (modified) libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp (+1-1)
- (modified) libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp (+1-1)
``````````diff
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
index 17a1e94b0ba6e..631052cad94b9 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
@@ -210,7 +210,7 @@ void test_on_test_type() {
}
}
-constexpr bool test_empty_emplace()
+TEST_CONSTEXPR_CXX20 bool test_empty_emplace()
{
optional<const int> opt;
auto &v = opt.emplace(42);
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
index 112ee213b42a6..c8c0b01060608 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
@@ -31,7 +31,7 @@ struct X
bool X::dtor_called = false;
-constexpr bool check_reset()
+TEST_CONSTEXPR_CXX20 bool check_reset()
{
{
optional<int> opt;
``````````
</details>
https://github.com/llvm/llvm-project/pull/94172
More information about the libcxx-commits
mailing list