Commit d0330a03 by Jonathan Wakely

libstdc++: Fixes for feature test macros (PR 91480)

Remove the non-standard __cpp_lib_allocator_is_always_equal macro and
add the missing macros for P1032R1.

	PR libstdc++/91480
	* include/bits/allocator.h (__cpp_lib_allocator_is_always_equal):
	Remove non-standard macro.
	* include/bits/stl_iterator.h (__cpp_lib_constexpr_iterator): Define
	to indicate P1032R1 support.
	* include/bits/stl_pair.h (__cpp_lib_constexpr_utility): Likewise.
	* include/std/string_view (__cpp_lib_constexpr_string_view): Likewise.
	* include/std/tuple (__cpp_lib_constexpr_tuple): Likewise.
	* include/std/version (__cpp_lib_allocator_is_always_equal): Remove.
	(__cpp_lib_constexpr_iterator, __cpp_lib_constexpr_string_view)
	(__cpp_lib_constexpr_tuple, __cpp_lib_constexpr_utility): Define.
	* testsuite/20_util/function_objects/constexpr_searcher.cc: Check
	feature test macro.
	* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/char/
	constexpr.cc: Likewise.
	* testsuite/24_iterators/insert_iterator/constexpr.cc: Likewise.
parent 162c40a4
2020-04-28 Jonathan Wakely <jwakely@redhat.com> 2020-04-28 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/91480
* include/bits/allocator.h (__cpp_lib_allocator_is_always_equal):
Remove non-standard macro.
* include/bits/stl_iterator.h (__cpp_lib_constexpr_iterator): Define
to indicate P1032R1 support.
* include/bits/stl_pair.h (__cpp_lib_constexpr_utility): Likewise.
* include/std/string_view (__cpp_lib_constexpr_string_view): Likewise.
* include/std/tuple (__cpp_lib_constexpr_tuple): Likewise.
* include/std/version (__cpp_lib_allocator_is_always_equal): Remove.
(__cpp_lib_constexpr_iterator, __cpp_lib_constexpr_string_view)
(__cpp_lib_constexpr_tuple, __cpp_lib_constexpr_utility): Define.
* testsuite/20_util/function_objects/constexpr_searcher.cc: Check
feature test macro.
* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: Likewise.
* testsuite/21_strings/basic_string_view/operations/copy/char/
constexpr.cc: Likewise.
* testsuite/24_iterators/insert_iterator/constexpr.cc: Likewise.
PR libstdc++/94831 PR libstdc++/94831
* include/bits/alloc_traits.h (_S_construct): Restore placement * include/bits/alloc_traits.h (_S_construct): Restore placement
new-expression for C++11/14/17 and call std::construct_at directly new-expression for C++11/14/17 and call std::construct_at directly
......
...@@ -50,9 +50,6 @@ ...@@ -50,9 +50,6 @@
#endif #endif
#define __cpp_lib_incomplete_container_elements 201505 #define __cpp_lib_incomplete_container_elements 201505
#if __cplusplus >= 201103L
# define __cpp_lib_allocator_is_always_equal 201411
#endif
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#if __cplusplus > 201703L #if __cplusplus > 201703L
# define __cpp_lib_array_constexpr 201811L # define __cpp_lib_array_constexpr 201811L
# define __cpp_lib_constexpr_iterator 201811L
#elif __cplusplus == 201703L #elif __cplusplus == 201703L
# define __cpp_lib_array_constexpr 201803L # define __cpp_lib_array_constexpr 201803L
#endif #endif
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#endif #endif
#if __cplusplus > 201703L #if __cplusplus > 201703L
# include <compare> # include <compare>
# define __cpp_lib_constexpr_utility 201811L
#endif #endif
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
......
...@@ -48,7 +48,10 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -48,7 +48,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_string_view 201803 # define __cpp_lib_string_view 201803L
#if __cplusplus > 201703L
# define __cpp_lib_constexpr_string_view 201811L
#endif
// Helper for basic_string and basic_string_view members. // Helper for basic_string and basic_string_view members.
constexpr size_t constexpr size_t
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <bits/invoke.h> #include <bits/invoke.h>
#if __cplusplus > 201703L #if __cplusplus > 201703L
# include <compare> # include <compare>
# define __cpp_lib_constexpr_tuple 201811L
#endif #endif
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#define __cpp_lib_result_of_sfinae 201210 #define __cpp_lib_result_of_sfinae 201210
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
# define __cpp_lib_allocator_is_always_equal 201411
# define __cpp_lib_allocator_traits_is_always_equal 201411 # define __cpp_lib_allocator_traits_is_always_equal 201411
# define __cpp_lib_shared_ptr_arrays 201611L # define __cpp_lib_shared_ptr_arrays 201611L
#endif #endif
...@@ -157,7 +156,7 @@ ...@@ -157,7 +156,7 @@
# define __cpp_lib_shared_mutex 201505 # define __cpp_lib_shared_mutex 201505
#endif #endif
#define __cpp_lib_shared_ptr_weak_type 201606 #define __cpp_lib_shared_ptr_weak_type 201606
#define __cpp_lib_string_view 201803 #define __cpp_lib_string_view 201803L
// #define __cpp_lib_to_chars 201611L // #define __cpp_lib_to_chars 201611L
#define __cpp_lib_unordered_map_try_emplace 201411 #define __cpp_lib_unordered_map_try_emplace 201411
#define __cpp_lib_variant 201606L #define __cpp_lib_variant 201606L
...@@ -201,8 +200,12 @@ ...@@ -201,8 +200,12 @@
#define __cpp_lib_constexpr_complex 201711L #define __cpp_lib_constexpr_complex 201711L
#define __cpp_lib_constexpr_dynamic_alloc 201907L #define __cpp_lib_constexpr_dynamic_alloc 201907L
#define __cpp_lib_constexpr_functional 201907L #define __cpp_lib_constexpr_functional 201907L
# define __cpp_lib_constexpr_iterator 201811L
#define __cpp_lib_constexpr_memory 201811L #define __cpp_lib_constexpr_memory 201811L
#define __cpp_lib_constexpr_numeric 201911L #define __cpp_lib_constexpr_numeric 201911L
#define __cpp_lib_constexpr_string_view 201811L
#define __cpp_lib_constexpr_tuple 201811L
#define __cpp_lib_constexpr_utility 201811L
#define __cpp_lib_erase_if 202002L #define __cpp_lib_erase_if 202002L
#define __cpp_lib_interpolate 201902L #define __cpp_lib_interpolate 201902L
#ifdef _GLIBCXX_HAS_GTHREADS #ifdef _GLIBCXX_HAS_GTHREADS
......
...@@ -19,6 +19,13 @@ ...@@ -19,6 +19,13 @@
// { dg-do compile { target c++2a } } // { dg-do compile { target c++2a } }
#include <functional> #include <functional>
#ifndef __cpp_lib_constexpr_functional
# error "Feature test macro for constexpr searcher is missing in <functional>"
#elif __cpp_lib_constexpr_functional < 201811L
# error "Feature test macro for constexpr searcher has wrong value in <functional>"
#endif
#include <string_view> #include <string_view>
const std::string_view const std::string_view
......
...@@ -18,9 +18,16 @@ ...@@ -18,9 +18,16 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
#include <memory>
#include <tuple> #include <tuple>
#ifndef __cpp_lib_constexpr_tuple
# error "Feature test macro for constexpr allocator constructors is missing in <tuple>"
#elif __cpp_lib_constexpr_tuple < 201811L
# error "Feature test macro for constexpr allocator constructors has wrong value in <tuple>"
#endif
#include <memory>
const std::allocator<int> alloc{}; const std::allocator<int> alloc{};
constexpr bool constexpr bool
......
...@@ -20,6 +20,12 @@ ...@@ -20,6 +20,12 @@
#include <string_view> #include <string_view>
#ifndef __cpp_lib_constexpr_string_view
# error "Feature test macro for constexpr copy is missing in <string_view>"
#elif __cpp_lib_constexpr_iterator < 201811L
# error "Feature test macro for constexpr copy has wrong value in <string_view>"
#endif
constexpr bool constexpr bool
test01() test01()
{ {
......
...@@ -20,6 +20,12 @@ ...@@ -20,6 +20,12 @@
#include <iterator> #include <iterator>
#ifndef __cpp_lib_constexpr_iterator
# error "Feature test macro for constexpr insert iterators is missing in <iterator>"
#elif __cpp_lib_constexpr_iterator < 201811L
# error "Feature test macro for constexpr insert iterators has wrong value in <iterator>"
#endif
struct container struct container
{ {
using value_type = int; using value_type = int;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment