From 46790405c5204d0c00501b1b972138d1d5481ba9 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 23 Apr 2020 17:39:21 +0100 Subject: [PATCH] libstdc++: Add missing feature test macros These macros all correspond to features that are already supported, but the macro was not defined when the feature was implemented. Backport from mainline 2020-04-22 Jonathan Wakely * include/bits/ptr_traits.h (__cpp_lib_constexpr_memory): Define to indicate P1006R1 support. (__cpp_lib_to_address): Define to indicate P0653R2 support. * include/std/memory (__cpp_lib_assume_aligned): Define to indicate P1007R3 support. * include/std/memory_resource (__cpp_lib_polymorphic_allocator): Define to indicate P0339R6 support. * include/std/string_view (__cpp_lib_starts_ends_with): Define to indicate P0457R2 support. * include/std/type_traits (__cpp_lib_is_nothrow_convertible): Define to indicate P0758R1 support. (__cpp_lib_remove_cvref): Define to indicate P0550R2 support. (__cpp_lib_type_identity): Define to indicate P0887R1 support. * include/std/version (__cpp_lib_is_nothrow_convertible) (__cpp_lib_remove_cvref, __cpp_lib_type_identity) (__cpp_lib_assume_aligned, __cpp_lib_constexpr_memory) (__cpp_lib_polymorphic_allocator, __cpp_lib_starts_ends_with) (__cpp_lib_to_address): Define. * testsuite/20_util/to_address/1_neg.cc: Adjust dg-error line number. --- libstdc++-v3/ChangeLog | 23 +++++++++++++++++++ libstdc++-v3/include/bits/ptr_traits.h | 3 +++ libstdc++-v3/include/std/memory | 1 + libstdc++-v3/include/std/memory_resource | 1 + libstdc++-v3/include/std/string_view | 1 + libstdc++-v3/include/std/type_traits | 4 ++++ libstdc++-v3/include/std/version | 9 ++++++++ .../testsuite/20_util/to_address/1_neg.cc | 2 +- 8 files changed, 43 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a481c9f79503..4589039deb59 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,28 @@ 2020-04-23 Jonathan Wakely + Backport from mainline + 2020-04-22 Jonathan Wakely + + * include/bits/ptr_traits.h (__cpp_lib_constexpr_memory): Define to + indicate P1006R1 support. + (__cpp_lib_to_address): Define to indicate P0653R2 support. + * include/std/memory (__cpp_lib_assume_aligned): Define to indicate + P1007R3 support. + * include/std/memory_resource (__cpp_lib_polymorphic_allocator): + Define to indicate P0339R6 support. + * include/std/string_view (__cpp_lib_starts_ends_with): Define to + indicate P0457R2 support. + * include/std/type_traits (__cpp_lib_is_nothrow_convertible): Define + to indicate P0758R1 support. + (__cpp_lib_remove_cvref): Define to indicate P0550R2 support. + (__cpp_lib_type_identity): Define to indicate P0887R1 support. + * include/std/version (__cpp_lib_is_nothrow_convertible) + (__cpp_lib_remove_cvref, __cpp_lib_type_identity) + (__cpp_lib_assume_aligned, __cpp_lib_constexpr_memory) + (__cpp_lib_polymorphic_allocator, __cpp_lib_starts_ends_with) + (__cpp_lib_to_address): Define. + * testsuite/20_util/to_address/1_neg.cc: Adjust dg-error line number. + * include/bits/stl_map.h (__cpp_lib_map_insertion): Add comment to non-standard macro. * include/bits/unordered_map.h (__cpp_lib_unordered_map_insertion): diff --git a/libstdc++-v3/include/bits/ptr_traits.h b/libstdc++-v3/include/bits/ptr_traits.h index cff56feb66fa..80ecf5b420d2 100644 --- a/libstdc++-v3/include/bits/ptr_traits.h +++ b/libstdc++-v3/include/bits/ptr_traits.h @@ -35,6 +35,7 @@ #include #if __cplusplus > 201703L +#define __cpp_lib_constexpr_memory 201811L namespace __gnu_debug { struct _Safe_iterator_base; } #endif @@ -180,6 +181,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::__to_address(__ptr.operator->()); } +#define __cpp_lib_to_address 201711L + /** * @brief Obtain address referenced by a pointer to an object * @param __ptr A pointer to an object diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory index b6950c76089a..cb8be4dc1293 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -157,6 +157,7 @@ inline pointer_safety get_pointer_safety() noexcept { return pointer_safety::relaxed; } #if __cplusplus > 201703L +#define __cpp_lib_assume_aligned 201811L /// Inform the compiler that a pointer is aligned. template [[nodiscard,__gnu__::__always_inline__]] diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource index 7ff5d17afe79..5b6ec60268aa 100644 --- a/libstdc++-v3/include/std/memory_resource +++ b/libstdc++-v3/include/std/memory_resource @@ -61,6 +61,7 @@ namespace pmr template class polymorphic_allocator; #else // C++20 +# define __cpp_lib_polymorphic_allocator 201902L template class polymorphic_allocator; #endif diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 42822cc41abb..bca3af89836c 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -310,6 +310,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #if __cplusplus > 201703L +#define __cpp_lib_starts_ends_with 201711L constexpr bool starts_with(basic_string_view __x) const noexcept { return this->substr(0, __x.size()) == __x; } diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 993f7e3153c8..18bcac824c38 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1362,6 +1362,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using type = decltype(__test<_From, _To>(0)); }; +#define __cpp_lib_is_nothrow_convertible 201806L /// is_nothrow_convertible template struct is_nothrow_convertible @@ -3027,6 +3028,8 @@ template #endif // C++17 #if __cplusplus > 201703L +#define __cpp_lib_remove_cvref 201711L + /// Remove references and cv-qualifiers. template struct remove_cvref @@ -3037,6 +3040,7 @@ template template using remove_cvref_t = __remove_cvref_t<_Tp>; +#define __cpp_lib_type_identity 201806L /// Identity metafunction. template struct type_identity { using type = _Tp; }; diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index a37ee0d5072d..fb0440d4e126 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -165,6 +165,7 @@ // c++2a #define __cpp_lib_bitops 201907L #define __cpp_lib_bounded_array_traits 201902L +// __cpp_lib_char8_t is defined in #if __cpp_impl_destroying_delete # define __cpp_lib_destroying_delete 201806L #endif @@ -173,14 +174,22 @@ #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED # define __cpp_lib_is_constant_evaluated 201811L #endif +#define __cpp_lib_is_nothrow_convertible 201806L +#define __cpp_lib_remove_cvref 201711L +#define __cpp_lib_type_identity 201806L #define __cpp_lib_unwrap_ref 201811L #if _GLIBCXX_HOSTED +#define __cpp_lib_assume_aligned 201811L #define __cpp_lib_bind_front 201907L #define __cpp_lib_constexpr_complex 201711L +#define __cpp_lib_constexpr_memory 201811L #define __cpp_lib_erase_if 202002L #define __cpp_lib_interpolate 201902L #define __cpp_lib_list_remove_return_type 201806L +#define __cpp_lib_polymorphic_allocator 201902L +#define __cpp_lib_starts_ends_with 201711L +#define __cpp_lib_to_address 201711L #endif #endif // C++2a #endif // C++17 diff --git a/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc b/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc index 33a0e32711aa..092413e65810 100644 --- a/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc @@ -17,7 +17,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do compile { target c++2a } } -// { dg-error "not a function pointer" "" { target *-*-* } 157 } +// { dg-error "not a function pointer" "" { target *-*-* } 158 } #include -- 2.47.3