diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-04-14 10:28:03 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-04-14 11:02:37 +0100 |
commit | d2f8208e9add01fe10ee56307cc79631b9995f74 (patch) | |
tree | f7dfdca479701c951d7b5ed395ee389565ce51c8 /libstdc++-v3 | |
parent | 8369b4e4c6433535981d377edc1d4abb799c9225 (diff) | |
download | gcc-d2f8208e9add01fe10ee56307cc79631b9995f74.tar.gz |
libstdc++: Fix missing and incorrect feature test macros [PR105269]
libstdc++-v3/ChangeLog:
PR libstdc++/105269
* include/bits/stl_vector.h (__cpp_lib_constexpr_vector):
Define.
* include/c_compatibility/stdatomic.h (__cpp_lib_stdatomic_h):
Define.
* include/std/optional (__cpp_lib_optional): Define new value
for C++23.
(__cpp_lib_monadic_optional): Remove.
* include/std/version (__cpp_lib_constexpr_vector): Define.
(__cpp_lib_stdatomic_h): Define.
(__cpp_lib_optional): Define new value for C++23.
(__cpp_lib_monadic_optional): Remove.
* testsuite/20_util/optional/monadic/and_then.cc: Adjust.
* testsuite/20_util/optional/requirements.cc: Adjust for C++23.
* testsuite/20_util/optional/version.cc: Likewise.
* testsuite/23_containers/vector/cons/constexpr.cc: Check
feature test macro.
* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc:
Likewise.
* testsuite/20_util/optional/monadic/version.cc: Removed.
* testsuite/23_containers/vector/requirements/version.cc: New test.
* testsuite/29_atomics/headers/stdatomic.h/version.cc: New test.
Diffstat (limited to 'libstdc++-v3')
12 files changed, 54 insertions, 23 deletions
diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 8e2fcc6f49b..b4ff3989a5d 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -62,8 +62,9 @@ #if __cplusplus >= 201103L #include <initializer_list> #endif -#if __cplusplus > 201703L +#if __cplusplus >= 202002L # include <compare> +#define __cpp_lib_constexpr_vector 201907L #endif #include <debug/assertions.h> diff --git a/libstdc++-v3/include/c_compatibility/stdatomic.h b/libstdc++-v3/include/c_compatibility/stdatomic.h index c97cbac984e..a51a84c2054 100644 --- a/libstdc++-v3/include/c_compatibility/stdatomic.h +++ b/libstdc++-v3/include/c_compatibility/stdatomic.h @@ -32,6 +32,8 @@ #if __cplusplus > 202002L #include <atomic> +#define __cpp_lib_stdatomic_h 202011L + #define _Atomic(_Tp) std::atomic<_Tp> using std::memory_order; diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index d6aece45fbf..791ef6f1994 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -60,10 +60,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ -#if __cplusplus == 201703L -# define __cpp_lib_optional 201606L -#else +#if __cplusplus > 202002L && __cpp_lib_concepts +# define __cpp_lib_optional 202110L +#elif __cplusplus >= 202002L # define __cpp_lib_optional 202106L +#else +# define __cpp_lib_optional 201606L #endif template<typename _Tp> @@ -1043,9 +1045,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return static_cast<_Tp>(std::forward<_Up>(__u)); } -#if __cplusplus > 202002L && __cpp_lib_concepts -#define __cpp_lib_monadic_optional 202110L - +#if __cpp_lib_optional >= 202110L // [optional.monadic] template<typename _Fn> diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 51f2110b68e..d8ec658484f 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -257,6 +257,7 @@ #define __cpp_lib_constexpr_string_view 201811L #define __cpp_lib_constexpr_tuple 201811L #define __cpp_lib_constexpr_utility 201811L +#define __cpp_lib_constexpr_vector 201907L #define __cpp_lib_erase_if 202002L #define __cpp_lib_generic_unordered_lookup 201811L #define __cpp_lib_interpolate 201902L @@ -312,7 +313,8 @@ #define __cpp_lib_invoke_r 202106L #define __cpp_lib_ios_noreplace 202200L #if __cpp_lib_concepts -# define __cpp_lib_monadic_optional 202110L +# undef __cpp_lib_optional +# define __cpp_lib_optional 202110L #endif #define __cpp_lib_move_only_function 202110L #if __cpp_lib_span @@ -321,6 +323,7 @@ #if _GLIBCXX_HAVE_STACKTRACE # define __cpp_lib_stacktrace 202011L #endif +#define __cpp_lib_stdatomic_h 202011L #define __cpp_lib_string_contains 202011L #if _GLIBCXX_USE_CXX11_ABI // Only supported with cxx11-abi # define __cpp_lib_string_resize_and_overwrite 202110L diff --git a/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc b/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc index 7cbec330ea0..c7e54efafee 100644 --- a/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc +++ b/libstdc++-v3/testsuite/20_util/optional/monadic/and_then.cc @@ -3,9 +3,7 @@ #include <optional> -#ifndef __cpp_lib_monadic_optional -# error "Feature test macro for monadic optional is missing in <optional>" -#elif __cpp_lib_monadic_optional < 202110L +#if __cpp_lib_optional < 202110L # error "Feature test macro for monadic optional has wrong value in <optional>" #endif diff --git a/libstdc++-v3/testsuite/20_util/optional/monadic/version.cc b/libstdc++-v3/testsuite/20_util/optional/monadic/version.cc deleted file mode 100644 index 90b2a90a5df..00000000000 --- a/libstdc++-v3/testsuite/20_util/optional/monadic/version.cc +++ /dev/null @@ -1,10 +0,0 @@ -// { dg-options "-std=gnu++23" } -// { dg-do preprocess { target c++23 } } - -#include <version> - -#ifndef __cpp_lib_monadic_optional -# error "Feature test macro for monadic optional is missing in <version>" -#elif __cpp_lib_monadic_optional < 202110L -# error "Feature test macro for monadic optional has wrong value in <version>" -#endif diff --git a/libstdc++-v3/testsuite/20_util/optional/requirements.cc b/libstdc++-v3/testsuite/20_util/optional/requirements.cc index d6a81529c74..a56680a6fb1 100644 --- a/libstdc++-v3/testsuite/20_util/optional/requirements.cc +++ b/libstdc++-v3/testsuite/20_util/optional/requirements.cc @@ -23,8 +23,10 @@ # error "Feature test macro for optional is missing in <optional>" #elif __cpp_lib_optional < 201606L # error "Feature test macro for optional has wrong value in <optional>" -#elif __cplusplus >= 202002L && __cpp_lib_optional < 202106L +#elif __cplusplus == 202002L && __cpp_lib_optional != 202106L # error "Feature test macro for optional has wrong value for C++20 in <optional>" +#elif __cplusplus > 202002L && __cpp_lib_optional != 202110L +# error "Feature test macro for optional has wrong value for C++23 in <version>" #endif #include <testsuite_hooks.h> diff --git a/libstdc++-v3/testsuite/20_util/optional/version.cc b/libstdc++-v3/testsuite/20_util/optional/version.cc index c18ecb8d48d..2fd52f7c194 100644 --- a/libstdc++-v3/testsuite/20_util/optional/version.cc +++ b/libstdc++-v3/testsuite/20_util/optional/version.cc @@ -6,6 +6,8 @@ # error "Feature test macro for optional is missing in <version>" #elif __cplusplus == 201703L && __cpp_lib_optional != 201606L # error "Feature test macro for optional has wrong value for C++17 in <version>" -#elif __cplusplus >= 202002L && __cpp_lib_optional < 202106L +#elif __cplusplus == 202002L && __cpp_lib_optional != 202106L # error "Feature test macro for optional has wrong value for C++20 in <version>" +#elif __cplusplus > 202002L && __cpp_lib_optional != 202110L +# error "Feature test macro for optional has wrong value for C++23 in <version>" #endif diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/constexpr.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/constexpr.cc index f5d2f08faf2..e6324ad4a0a 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/cons/constexpr.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/constexpr.cc @@ -3,6 +3,13 @@ // { dg-xfail-if "not supported" { debug_mode } } #include <vector> + +#ifndef __cpp_lib_constexpr_vector +# error "Feature test macro for constexpr vector is missing in <vector>" +#elif __cpp_lib_constexpr_vector != 201907L +# error "Feature test macro for constexpr vector has wrong value in <vector>" +#endif + #include <testsuite_hooks.h> #include <testsuite_iterators.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/version.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/version.cc new file mode 100644 index 00000000000..c85e060f048 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/version.cc @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++20" } +// { dg-do preprocess { target c++20 } } + +#include <version> + +#ifndef __cpp_lib_constexpr_vector +# error "Feature test macro for constexpr vector is missing in <version>" +#elif __cpp_lib_constexpr_vector != 201907L +# error "Feature test macro for constexpr vector has wrong value in <version>" +#endif diff --git a/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc index 6dd4f5b00ca..edf19960cbb 100644 --- a/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc +++ b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/c_compat.cc @@ -3,6 +3,12 @@ #include <stdatomic.h> +#ifndef __cpp_lib_stdatomic_h +# error "Feature test macro for stdatomic.h is missing in <stdatomic.h>" +#elif __cpp_lib_stdatomic_h != 202011L +# error "Feature test macro for stdatomic.h has wrong value in <stdatomic.h>" +#endif + #ifndef ATOMIC_BOOL_LOCK_FREE #error ATOMIC_BOOL_LOCK_FREE is not defined in <stdatomic.h> #endif diff --git a/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/version.cc b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/version.cc new file mode 100644 index 00000000000..dbaf6bc59d3 --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/version.cc @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++23" } +// { dg-do preprocess { target c++23 } } + +#include <version> + +#ifndef __cpp_lib_stdatomic_h +# error "Feature test macro for stdatomic.h is missing in <version>" +#elif __cpp_lib_stdatomic_h != 202011L +# error "Feature test macro for stdatomic.h has wrong value in <version>" +#endif |