diff --git a/stl/inc/memory b/stl/inc/memory index 50c94371a2a..9b30d903676 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -3611,6 +3611,7 @@ basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Out, c } // GARBAGE COLLECTION +#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 enum class pointer_safety { relaxed, preferred, strict }; inline void declare_reachable(void*) {} @@ -3627,6 +3628,7 @@ inline void undeclare_no_pointers(char*, size_t) {} inline pointer_safety get_pointer_safety() noexcept { return pointer_safety::relaxed; } +#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 // STRUCT TEMPLATE owner_less template diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 6ddb9575e6c..97692b89373 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -265,6 +265,7 @@ // P1682R3 to_underlying() For Enumerations // P1989R2 Range Constructor For string_view // P2166R1 Prohibiting basic_string And basic_string_view Construction From nullptr +// P2186R2 Removing Garbage Collection Support // Parallel Algorithms Notes // C++ allows an implementation to implement parallel algorithms as calls to the serial algorithms. @@ -1124,6 +1125,16 @@ #define _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 (_HAS_FEATURES_REMOVED_IN_CXX20) #endif // _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 + +#ifndef _HAS_FEATURES_REMOVED_IN_CXX23 +#define _HAS_FEATURES_REMOVED_IN_CXX23 (!_HAS_CXX23) +#endif // _HAS_FEATURES_REMOVED_IN_CXX23 + +// P2186R2 Removing Garbage Collection Support +#ifndef _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 +#define _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 (_HAS_FEATURES_REMOVED_IN_CXX23) +#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 + // LIBRARY FEATURE-TEST MACROS // C++14 diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 65593fd2a23..1ca004839ba 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -659,6 +659,11 @@ std/language.support/support.limits/support.limits.general/memory.version.pass.c # should work std/language.support/support.limits/support.limits.general/variant.version.pass.cpp FAIL +# libc++ doesn't implement P2186R2 Removing Garbage Collection Support +std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp FAIL +std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp FAIL +std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp FAIL + # *** LIKELY STL BUGS *** # Not yet analyzed, likely STL bugs. Assertions and other runtime failures. std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp FAIL diff --git a/tests/libcxx/skipped_tests.txt b/tests/libcxx/skipped_tests.txt index 45df6d8fa7b..7dbc78f7c9b 100644 --- a/tests/libcxx/skipped_tests.txt +++ b/tests/libcxx/skipped_tests.txt @@ -659,6 +659,11 @@ language.support\support.limits\support.limits.general\memory.version.pass.cpp # should work language.support\support.limits\support.limits.general\variant.version.pass.cpp +# libc++ doesn't implement P2186R2 Removing Garbage Collection Support +utilities\memory\util.dynamic.safety\get_pointer_safety.pass.cpp +utilities\memory\util.dynamic.safety\declare_no_pointers.pass.cpp +utilities\memory\util.dynamic.safety\declare_reachable.pass.cpp + # *** LIKELY STL BUGS *** # Not yet analyzed, likely STL bugs. Assertions and other runtime failures. numerics\rand\rand.dis\rand.dist.bern\rand.dist.bern.bin\eval_param.pass.cpp diff --git a/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp b/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp index e896431316d..c78df009118 100644 --- a/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp +++ b/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp @@ -961,8 +961,10 @@ void memory_test() { default_delete dd1{default_delete{}}; dd1(new int[5]); +#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 int* int_ptr{}; undeclare_reachable(int_ptr); +#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 auto sptr = make_shared(5); auto wptr = weak_ptr(sptr); diff --git a/tests/tr1/tests/memory/test.cpp b/tests/tr1/tests/memory/test.cpp index 5daa40cb0ce..ff13e441d83 100644 --- a/tests/tr1/tests/memory/test.cpp +++ b/tests/tr1/tests/memory/test.cpp @@ -199,6 +199,7 @@ void test_autoptr() { // test auto_ptr CHECK_INT(cnt, 0); } +#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 void test_gc() { // test garbage collection control char x; STD declare_reachable(&x); @@ -209,11 +210,14 @@ void test_gc() { // test garbage collection control || (int) STD get_pointer_safety() == (int) STD pointer_safety::preferred || (int) STD get_pointer_safety() == (int) STD pointer_safety::strict); } +#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 void test_main() { // test basic properties of memory definitions test_alloc(); test_uninit(); test_tempbuf(); test_autoptr(); +#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 test_gc(); +#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 }