]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add freestanding feature test macros (P2407R5)
authorJonathan Wakely <jwakely@redhat.com>
Mon, 20 Nov 2023 21:39:58 +0000 (21:39 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 21 Nov 2023 15:58:21 +0000 (15:58 +0000)
This C++26 change makes several classes "partially freestanding", but we
already fully supported them in freestanding mode. All we need to do is
define the new feature test macros and add tests for them.

libstdc++-v3/ChangeLog:

* include/bits/version.def (freestanding_algorithm)
(freestanding_array, freestanding_optional)
(freestanding_string_view, freestanding_variant): Add.
* include/bits/version.h: Regenerate.
* include/std/algorithm (__glibcxx_want_freestanding_algorithm):
Define.
* include/std/array (__glibcxx_want_freestanding_array):
Define.
* include/std/optional (__glibcxx_want_freestanding_optional):
Define.
* include/std/string_view
(__glibcxx_want_freestanding_string_view): Define.
* include/std/variant (__glibcxx_want_freestanding_variant):
Define.
* testsuite/20_util/optional/version.cc: Add checks for
__cpp_lib_freestanding_optional.
* testsuite/20_util/variant/version.cc: Add checks for
__cpp_lib_freestanding_variant.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.
* testsuite/21_strings/basic_string_view/requirements/version.cc:
New test.
* testsuite/23_containers/array/requirements/version.cc: New
test.
* testsuite/25_algorithms/fill_n/requirements/version.cc: New
test.
* testsuite/25_algorithms/swap_ranges/requirements/version.cc:
New test.

14 files changed:
libstdc++-v3/include/bits/version.def
libstdc++-v3/include/bits/version.h
libstdc++-v3/include/std/algorithm
libstdc++-v3/include/std/array
libstdc++-v3/include/std/optional
libstdc++-v3/include/std/string_view
libstdc++-v3/include/std/variant
libstdc++-v3/testsuite/20_util/optional/version.cc
libstdc++-v3/testsuite/20_util/variant/version.cc
libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/version.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/array/requirements/version.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/version.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/version.cc [new file with mode: 0644]

index 59a751da77b338a62950c014316344b53d28f630..1c49ecea25e3f230d0bdc1fb73ef0291f494db0a 100644 (file)
@@ -1348,15 +1348,60 @@ ftms = {
   };
 };
 
+ftms = {
+  name = freestanding_algorithm;
+  values = {
+    v = 202311;
+    // This is a C++26 feature, but we support it in C++23.
+    cxxmin = 23;
+  };
+};
+
+ftms = {
+  name = freestanding_array;
+  values = {
+    v = 202311;
+    // This is a C++26 feature, but we support it in C++23.
+    cxxmin = 23;
+  };
+};
+
 ftms = {
   name = freestanding_expected;
   values = {
     v = 202311;
     cxxmin = 23;
+    // This is a C++26 feature, but we support it in C++23.
     extra_cond = "__cpp_lib_expected";
   };
 };
 
+ftms = {
+  name = freestanding_optional;
+  values = {
+    v = 202311;
+    // This is a C++26 feature, but we support it in C++23.
+    cxxmin = 23;
+  };
+};
+
+ftms = {
+  name = freestanding_string_view;
+  values = {
+    v = 202311;
+    // This is a C++26 feature, but we support it in C++23.
+    cxxmin = 23;
+  };
+};
+
+ftms = {
+  name = freestanding_variant;
+  values = {
+    v = 202311;
+    // This is a C++26 feature, but we support it in C++23.
+    cxxmin = 23;
+  };
+};
 
 ftms = {
   name = invoke_r;
index b3dbfbbcd0dc96e32b34d575b75048266b6fdef0..a61d482c6629407ab5edc1fea7de76ecbf5c5248 100644 (file)
 #undef __glibcxx_want_expected
 
 // from version.def line 1352
+#if !defined(__cpp_lib_freestanding_algorithm)
+# if (__cplusplus >= 202100L)
+#  define __glibcxx_freestanding_algorithm 202311L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_freestanding_algorithm)
+#   define __cpp_lib_freestanding_algorithm 202311L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_freestanding_algorithm) && defined(__glibcxx_want_freestanding_algorithm) */
+#undef __glibcxx_want_freestanding_algorithm
+
+// from version.def line 1361
+#if !defined(__cpp_lib_freestanding_array)
+# if (__cplusplus >= 202100L)
+#  define __glibcxx_freestanding_array 202311L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_freestanding_array)
+#   define __cpp_lib_freestanding_array 202311L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_freestanding_array) && defined(__glibcxx_want_freestanding_array) */
+#undef __glibcxx_want_freestanding_array
+
+// from version.def line 1370
 #if !defined(__cpp_lib_freestanding_expected)
 # if (__cplusplus >= 202100L) && (__cpp_lib_expected)
 #  define __glibcxx_freestanding_expected 202311L
 #endif /* !defined(__cpp_lib_freestanding_expected) && defined(__glibcxx_want_freestanding_expected) */
 #undef __glibcxx_want_freestanding_expected
 
-// from version.def line 1362
+// from version.def line 1380
+#if !defined(__cpp_lib_freestanding_optional)
+# if (__cplusplus >= 202100L)
+#  define __glibcxx_freestanding_optional 202311L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_freestanding_optional)
+#   define __cpp_lib_freestanding_optional 202311L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_freestanding_optional) && defined(__glibcxx_want_freestanding_optional) */
+#undef __glibcxx_want_freestanding_optional
+
+// from version.def line 1389
+#if !defined(__cpp_lib_freestanding_string_view)
+# if (__cplusplus >= 202100L)
+#  define __glibcxx_freestanding_string_view 202311L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_freestanding_string_view)
+#   define __cpp_lib_freestanding_string_view 202311L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_freestanding_string_view) && defined(__glibcxx_want_freestanding_string_view) */
+#undef __glibcxx_want_freestanding_string_view
+
+// from version.def line 1398
+#if !defined(__cpp_lib_freestanding_variant)
+# if (__cplusplus >= 202100L)
+#  define __glibcxx_freestanding_variant 202311L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_freestanding_variant)
+#   define __cpp_lib_freestanding_variant 202311L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_freestanding_variant) && defined(__glibcxx_want_freestanding_variant) */
+#undef __glibcxx_want_freestanding_variant
+
+// from version.def line 1407
 #if !defined(__cpp_lib_invoke_r)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_invoke_r 202106L
 #endif /* !defined(__cpp_lib_invoke_r) && defined(__glibcxx_want_invoke_r) */
 #undef __glibcxx_want_invoke_r
 
-// from version.def line 1370
+// from version.def line 1415
 #if !defined(__cpp_lib_is_scoped_enum)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_is_scoped_enum 202011L
 #endif /* !defined(__cpp_lib_is_scoped_enum) && defined(__glibcxx_want_is_scoped_enum) */
 #undef __glibcxx_want_is_scoped_enum
 
-// from version.def line 1378
+// from version.def line 1423
 #if !defined(__cpp_lib_reference_from_temporary)
 # if (__cplusplus >= 202100L) && (__has_builtin(__reference_constructs_from_temporary) && __has_builtin(__reference_converts_from_temporary))
 #  define __glibcxx_reference_from_temporary 202202L
 #endif /* !defined(__cpp_lib_reference_from_temporary) && defined(__glibcxx_want_reference_from_temporary) */
 #undef __glibcxx_want_reference_from_temporary
 
-// from version.def line 1389
+// from version.def line 1434
 #if !defined(__cpp_lib_to_underlying)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_to_underlying 202102L
 #endif /* !defined(__cpp_lib_to_underlying) && defined(__glibcxx_want_to_underlying) */
 #undef __glibcxx_want_to_underlying
 
-// from version.def line 1397
+// from version.def line 1442
 #if !defined(__cpp_lib_unreachable)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_unreachable 202202L
 #endif /* !defined(__cpp_lib_unreachable) && defined(__glibcxx_want_unreachable) */
 #undef __glibcxx_want_unreachable
 
-// from version.def line 1405
+// from version.def line 1450
 #if !defined(__cpp_lib_ranges_zip)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_zip 202110L
 #endif /* !defined(__cpp_lib_ranges_zip) && defined(__glibcxx_want_ranges_zip) */
 #undef __glibcxx_want_ranges_zip
 
-// from version.def line 1413
+// from version.def line 1458
 #if !defined(__cpp_lib_ranges_chunk)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_chunk 202202L
 #endif /* !defined(__cpp_lib_ranges_chunk) && defined(__glibcxx_want_ranges_chunk) */
 #undef __glibcxx_want_ranges_chunk
 
-// from version.def line 1421
+// from version.def line 1466
 #if !defined(__cpp_lib_ranges_slide)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_slide 202202L
 #endif /* !defined(__cpp_lib_ranges_slide) && defined(__glibcxx_want_ranges_slide) */
 #undef __glibcxx_want_ranges_slide
 
-// from version.def line 1429
+// from version.def line 1474
 #if !defined(__cpp_lib_ranges_chunk_by)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_chunk_by 202202L
 #endif /* !defined(__cpp_lib_ranges_chunk_by) && defined(__glibcxx_want_ranges_chunk_by) */
 #undef __glibcxx_want_ranges_chunk_by
 
-// from version.def line 1437
+// from version.def line 1482
 #if !defined(__cpp_lib_ranges_join_with)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_join_with 202202L
 #endif /* !defined(__cpp_lib_ranges_join_with) && defined(__glibcxx_want_ranges_join_with) */
 #undef __glibcxx_want_ranges_join_with
 
-// from version.def line 1445
+// from version.def line 1490
 #if !defined(__cpp_lib_ranges_repeat)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_repeat 202207L
 #endif /* !defined(__cpp_lib_ranges_repeat) && defined(__glibcxx_want_ranges_repeat) */
 #undef __glibcxx_want_ranges_repeat
 
-// from version.def line 1453
+// from version.def line 1498
 #if !defined(__cpp_lib_ranges_stride)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_stride 202207L
 #endif /* !defined(__cpp_lib_ranges_stride) && defined(__glibcxx_want_ranges_stride) */
 #undef __glibcxx_want_ranges_stride
 
-// from version.def line 1461
+// from version.def line 1506
 #if !defined(__cpp_lib_ranges_cartesian_product)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_cartesian_product 202207L
 #endif /* !defined(__cpp_lib_ranges_cartesian_product) && defined(__glibcxx_want_ranges_cartesian_product) */
 #undef __glibcxx_want_ranges_cartesian_product
 
-// from version.def line 1469
+// from version.def line 1514
 #if !defined(__cpp_lib_ranges_as_rvalue)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_as_rvalue 202207L
 #endif /* !defined(__cpp_lib_ranges_as_rvalue) && defined(__glibcxx_want_ranges_as_rvalue) */
 #undef __glibcxx_want_ranges_as_rvalue
 
-// from version.def line 1477
+// from version.def line 1522
 #if !defined(__cpp_lib_ranges_as_const)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_as_const 202207L
 #endif /* !defined(__cpp_lib_ranges_as_const) && defined(__glibcxx_want_ranges_as_const) */
 #undef __glibcxx_want_ranges_as_const
 
-// from version.def line 1485
+// from version.def line 1530
 #if !defined(__cpp_lib_ranges_enumerate)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_enumerate 202302L
 #endif /* !defined(__cpp_lib_ranges_enumerate) && defined(__glibcxx_want_ranges_enumerate) */
 #undef __glibcxx_want_ranges_enumerate
 
-// from version.def line 1493
+// from version.def line 1538
 #if !defined(__cpp_lib_ranges_fold)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_fold 202207L
 #endif /* !defined(__cpp_lib_ranges_fold) && defined(__glibcxx_want_ranges_fold) */
 #undef __glibcxx_want_ranges_fold
 
-// from version.def line 1501
+// from version.def line 1546
 #if !defined(__cpp_lib_ranges_contains)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_contains 202207L
 #endif /* !defined(__cpp_lib_ranges_contains) && defined(__glibcxx_want_ranges_contains) */
 #undef __glibcxx_want_ranges_contains
 
-// from version.def line 1509
+// from version.def line 1554
 #if !defined(__cpp_lib_ranges_iota)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_iota 202202L
 #endif /* !defined(__cpp_lib_ranges_iota) && defined(__glibcxx_want_ranges_iota) */
 #undef __glibcxx_want_ranges_iota
 
-// from version.def line 1517
+// from version.def line 1562
 #if !defined(__cpp_lib_ranges_find_last)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_ranges_find_last 202207L
 #endif /* !defined(__cpp_lib_ranges_find_last) && defined(__glibcxx_want_ranges_find_last) */
 #undef __glibcxx_want_ranges_find_last
 
-// from version.def line 1525
+// from version.def line 1570
 #if !defined(__cpp_lib_constexpr_bitset)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED && (__cpp_constexpr_dynamic_alloc)
 #  define __glibcxx_constexpr_bitset 202202L
 #endif /* !defined(__cpp_lib_constexpr_bitset) && defined(__glibcxx_want_constexpr_bitset) */
 #undef __glibcxx_want_constexpr_bitset
 
-// from version.def line 1535
+// from version.def line 1580
 #if !defined(__cpp_lib_stdatomic_h)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_stdatomic_h 202011L
 #endif /* !defined(__cpp_lib_stdatomic_h) && defined(__glibcxx_want_stdatomic_h) */
 #undef __glibcxx_want_stdatomic_h
 
-// from version.def line 1543
+// from version.def line 1588
 #if !defined(__cpp_lib_adaptor_iterator_pair_constructor)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
 #  define __glibcxx_adaptor_iterator_pair_constructor 202106L
 #endif /* !defined(__cpp_lib_adaptor_iterator_pair_constructor) && defined(__glibcxx_want_adaptor_iterator_pair_constructor) */
 #undef __glibcxx_want_adaptor_iterator_pair_constructor
 
-// from version.def line 1552
+// from version.def line 1597
 #if !defined(__cpp_lib_formatters)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
 #  define __glibcxx_formatters 202302L
 #endif /* !defined(__cpp_lib_formatters) && defined(__glibcxx_want_formatters) */
 #undef __glibcxx_want_formatters
 
-// from version.def line 1561
+// from version.def line 1606
 #if !defined(__cpp_lib_forward_like)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_forward_like 202207L
 #endif /* !defined(__cpp_lib_forward_like) && defined(__glibcxx_want_forward_like) */
 #undef __glibcxx_want_forward_like
 
-// from version.def line 1569
+// from version.def line 1614
 #if !defined(__cpp_lib_ios_noreplace)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
 #  define __glibcxx_ios_noreplace 202207L
 #endif /* !defined(__cpp_lib_ios_noreplace) && defined(__glibcxx_want_ios_noreplace) */
 #undef __glibcxx_want_ios_noreplace
 
-// from version.def line 1578
+// from version.def line 1623
 #if !defined(__cpp_lib_move_only_function)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
 #  define __glibcxx_move_only_function 202110L
 #endif /* !defined(__cpp_lib_move_only_function) && defined(__glibcxx_want_move_only_function) */
 #undef __glibcxx_want_move_only_function
 
-// from version.def line 1587
+// from version.def line 1632
 #if !defined(__cpp_lib_out_ptr)
 # if (__cplusplus >= 202100L)
 #  define __glibcxx_out_ptr 202311L
 #endif /* !defined(__cpp_lib_out_ptr) && defined(__glibcxx_want_out_ptr) */
 #undef __glibcxx_want_out_ptr
 
-// from version.def line 1595
+// from version.def line 1640
 #if !defined(__cpp_lib_spanstream)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED && (__glibcxx_span)
 #  define __glibcxx_spanstream 202106L
 #endif /* !defined(__cpp_lib_spanstream) && defined(__glibcxx_want_spanstream) */
 #undef __glibcxx_want_spanstream
 
-// from version.def line 1605
+// from version.def line 1650
 #if !defined(__cpp_lib_stacktrace)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED && (_GLIBCXX_HAVE_STACKTRACE)
 #  define __glibcxx_stacktrace 202011L
 #endif /* !defined(__cpp_lib_stacktrace) && defined(__glibcxx_want_stacktrace) */
 #undef __glibcxx_want_stacktrace
 
-// from version.def line 1615
+// from version.def line 1660
 #if !defined(__cpp_lib_string_contains)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
 #  define __glibcxx_string_contains 202011L
 #endif /* !defined(__cpp_lib_string_contains) && defined(__glibcxx_want_string_contains) */
 #undef __glibcxx_want_string_contains
 
-// from version.def line 1624
+// from version.def line 1669
 #if !defined(__cpp_lib_string_resize_and_overwrite)
 # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
 #  define __glibcxx_string_resize_and_overwrite 202110L
 #endif /* !defined(__cpp_lib_string_resize_and_overwrite) && defined(__glibcxx_want_string_resize_and_overwrite) */
 #undef __glibcxx_want_string_resize_and_overwrite
 
-// from version.def line 1633
+// from version.def line 1678
 #if !defined(__cpp_lib_fstream_native_handle)
 # if (__cplusplus >  202302L) && _GLIBCXX_HOSTED
 #  define __glibcxx_fstream_native_handle 202306L
 #endif /* !defined(__cpp_lib_fstream_native_handle) && defined(__glibcxx_want_fstream_native_handle) */
 #undef __glibcxx_want_fstream_native_handle
 
-// from version.def line 1642
+// from version.def line 1687
 #if !defined(__cpp_lib_ratio)
 # if (__cplusplus >  202302L)
 #  define __glibcxx_ratio 202306L
 #endif /* !defined(__cpp_lib_ratio) && defined(__glibcxx_want_ratio) */
 #undef __glibcxx_want_ratio
 
-// from version.def line 1650
+// from version.def line 1695
 #if !defined(__cpp_lib_saturation_arithmetic)
 # if (__cplusplus >  202302L)
 #  define __glibcxx_saturation_arithmetic 202311L
 #endif /* !defined(__cpp_lib_saturation_arithmetic) && defined(__glibcxx_want_saturation_arithmetic) */
 #undef __glibcxx_want_saturation_arithmetic
 
-// from version.def line 1658
+// from version.def line 1703
 #if !defined(__cpp_lib_to_string)
 # if (__cplusplus >  202302L) && _GLIBCXX_HOSTED && (__glibcxx_to_chars)
 #  define __glibcxx_to_string 202306L
index d7fab417111b3f2f11c4c1e23cb392328f74e586..40aff5018aaccf11d86397f752aa30786db58643 100644 (file)
@@ -65,6 +65,7 @@
 
 #define __glibcxx_want_clamp
 #define __glibcxx_want_constexpr_algorithms
+#define __glibcxx_want_freestanding_algorithm
 #define __glibcxx_want_parallel_algorithm
 #define __glibcxx_want_ranges_contains
 #define __glibcxx_want_ranges_find_last
index d34ec5c7c433db1dc8403b26a00f8a184e898df0..ddc15b6788d8299f2c282c6401d2fa20bcc9b3d6 100644 (file)
@@ -46,6 +46,7 @@
 #include <debug/assertions.h>
 
 #define __glibcxx_want_array_constexpr
+#define __glibcxx_want_freestanding_array
 #define __glibcxx_want_nonmember_container_access
 #define __glibcxx_want_to_array
 #include <bits/version.h>
index a8c97717b724770fce24f2d54f5b1335747a04d5..937486fcc3bae37bffe1856ccce69af7c7e547ea 100644 (file)
@@ -32,6 +32,7 @@
 
 #pragma GCC system_header
 
+#define __glibcxx_want_freestanding_optional
 #define __glibcxx_want_optional
 #include <bits/version.h>
 
index cbb6bb0928fa9c79703c7b39402ce702d5f1c7d6..44d13b403ccbd5b127a9aabc754c2525527b33e1 100644 (file)
@@ -36,8 +36,9 @@
 #pragma GCC system_header
 
 #define __glibcxx_want_constexpr_char_traits
-#define __glibcxx_want_string_view
 #define __glibcxx_want_constexpr_string_view
+#define __glibcxx_want_freestanding_string_view
+#define __glibcxx_want_string_view
 #define __glibcxx_want_starts_ends_with
 #define __glibcxx_want_string_contains
 #include <bits/version.h>
index 7f24e760bb12e9ae81ce069361a6effedb01af13..36bb37c20e5855164c82a3b31117ad6c73e3f34e 100644 (file)
@@ -31,6 +31,7 @@
 
 #pragma GCC system_header
 
+#define __glibcxx_want_freestanding_variant
 #define __glibcxx_want_variant
 #include <bits/version.h>
 
index 7e63d425796244eb86ec70fa73030424063778d2..657a3992422a9c6655cc26a7d5fb718e1d3cd0e9 100644 (file)
 #elif __cplusplus > 202002L && __cpp_lib_optional != 202110L
 # error "Feature test macro for optional has wrong value for C++23 in <version>"
 #endif
+
+#if __cplusplus >= 202302L
+#ifndef __cpp_lib_freestanding_optional
+# error "Feature test macro for freestanding std::optional is missing in <version>"
+#elif __cpp_lib_freestanding_optional < 202311L
+# error "Feature test macro for freestanding std::optional has wrong value in <version>"
+#endif
+#endif
+
+#undef __cpp_lib_optional
+#undef __cpp_lib_freestanding_optional
+#include <optional>
+
+#if __cplusplus >= 202302L
+#ifndef __cpp_lib_freestanding_optional
+# error "Feature test macro for freestanding std::optional is missing in <optional>"
+#elif __cpp_lib_freestanding_optional < 202311L
+# error "Feature test macro for freestanding std::optional has wrong value in <optional>"
+#endif
+#endif
index fd251dd37684243857b2c82be478ace4509609c0..f7985322cc5c08db09e6a4343b85ce0511fa7004 100644 (file)
 #elif __cplusplus >= 202002L && __cpp_lib_variant < 202106L
 # error "Feature test macro for variant has wrong value for C++20 in <version>"
 #endif
+
+#if __cplusplus >= 202302L
+#ifndef __cpp_lib_freestanding_variant
+# error "Feature test macro for freestanding std::variant is missing in <version>"
+#elif __cpp_lib_freestanding_variant < 202311L
+# error "Feature test macro for freestanding std::variant has wrong value in <version>"
+#endif
+#endif
+
+#undef __cpp_lib_variant
+#undef __cpp_lib_freestanding_variant
+#include <variant>
+
+#if __cplusplus >= 202302L
+#ifndef __cpp_lib_freestanding_variant
+# error "Feature test macro for freestanding std::variant is missing in <variant>"
+#elif __cpp_lib_freestanding_variant < 202311L
+# error "Feature test macro for freestanding std::variant has wrong value in <variant>"
+#endif
+#endif
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/version.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/version.cc
new file mode 100644 (file)
index 0000000..cc36699
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do compile { target c++23 } }
+// { dg-add-options no_pch }
+
+#include <string_view>
+
+#ifndef __cpp_lib_freestanding_string_view
+# error "Feature test macro for freestanding std::string_view is missing in <string_view>"
+#elif __cpp_lib_freestanding_string_view < 202311L
+# error "Feature test macro for freestanding std::string_view has wrong value in <string_view>"
+#endif
+
+#undef __cpp_lib_freestanding_string_view
+#include <version>
+
+#ifndef __cpp_lib_freestanding_string_view
+# error "Feature test macro for freestanding std::string_view is missing in <version>"
+#elif __cpp_lib_freestanding_string_view < 202311L
+# error "Feature test macro for freestanding std::string_view has wrong value in <version>"
+#endif
diff --git a/libstdc++-v3/testsuite/23_containers/array/requirements/version.cc b/libstdc++-v3/testsuite/23_containers/array/requirements/version.cc
new file mode 100644 (file)
index 0000000..1930805
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do preprocess { target c++23 } }
+// { dg-add-options no_pch }
+
+#include <array>
+
+#ifndef __cpp_lib_freestanding_array
+# error "Feature test macro for freestanding std::array is missing in <array>"
+#elif __cpp_lib_freestanding_array < 202311L
+# error "Feature test macro for freestanding std::array has wrong value in <array>"
+#endif
+
+#undef __cpp_lib_freestanding_array
+#include <version>
+
+#ifndef __cpp_lib_freestanding_array
+# error "Feature test macro for freestanding std::array is missing in <version>"
+#elif __cpp_lib_freestanding_array < 202311L
+# error "Feature test macro for freestanding std::array has wrong value in <version>"
+#endif
index bf64d298579d333bb52c69a4d5f0dee343047d52..e1c92f85b7ed821c3f7c972066b4ae343f2a8e0d 100644 (file)
@@ -26,6 +26,6 @@ int n1 = std::get<1>(a);
 int n2 = std::get<1>(std::move(a));
 int n3 = std::get<1>(ca);
 
-// { dg-error "static assertion failed" "" { target *-*-* } 391 }
-// { dg-error "static assertion failed" "" { target *-*-* } 400 }
-// { dg-error "static assertion failed" "" { target *-*-* } 409 }
+// { dg-error "static assertion failed" "" { target *-*-* } 392 }
+// { dg-error "static assertion failed" "" { target *-*-* } 401 }
+// { dg-error "static assertion failed" "" { target *-*-* } 410 }
diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/version.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/version.cc
new file mode 100644 (file)
index 0000000..6691aff
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do preprocess { target c++23 } }
+// { dg-add-options no_pch }
+
+#include <algorithm>
+
+#ifndef __cpp_lib_freestanding_algorithm
+# error "Feature test macro for freestanding fill_n is missing in <algorithm>"
+#elif __cpp_lib_freestanding_algorithm < 202311L
+# error "Feature test macro for freestanding fill_n has wrong value in <algorithm>"
+#endif
+
+#undef __cpp_lib_freestanding_algorithm
+#include <version>
+
+#ifndef __cpp_lib_freestanding_algorithm
+# error "Feature test macro for freestanding fill_n is missing in <version>"
+#elif __cpp_lib_freestanding_algorithm < 202311L
+# error "Feature test macro for freestanding fill_n has wrong value in <version>"
+#endif
diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/version.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/version.cc
new file mode 100644 (file)
index 0000000..2a65e7c
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do preprocess { target c++23 } }
+// { dg-add-options no_pch }
+
+#include <algorithm>
+
+#ifndef __cpp_lib_freestanding_algorithm
+# error "Feature test macro for freestanding swap_ranges is missing in <algorithm>"
+#elif __cpp_lib_freestanding_algorithm < 202311L
+# error "Feature test macro for freestanding swap_ranges has wrong value in <algorithm>"
+#endif
+
+#undef __cpp_lib_freestanding_algorithm
+#include <version>
+
+#ifndef __cpp_lib_freestanding_algorithm
+# error "Feature test macro for freestanding swap_ranges is missing in <version>"
+#elif __cpp_lib_freestanding_algorithm < 202311L
+# error "Feature test macro for freestanding swap_ranges has wrong value in <version>"
+#endif