From e0f58444e126e80a0d43eb5b88622799910195e6 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Fri, 19 Nov 2021 09:52:28 -0500 Subject: [PATCH] [libc++] Fix feature test macro for __cpp_lib_to_chars We would have been defining it in instead of . For the time being, this doesn't change anything since we don't implement the feature test macro anyways. Also, as a fly-by, this removes obsolete feature test macro tests. There was a brief time back in the days when we wrote feature test macro tests manually. In particular, we had test files for __cpp_lib_to_chars and __cpp_lib_memory_resource. Since we now have a principled way of generating these tests with scripts, this commit removes the obsolete (and empty) tests for these two feature test macros. Differential Revision: https://reviews.llvm.org/D114243 --- libcxx/include/version | 2 +- .../support.limits.general/charconv.pass.cpp | 33 --------- .../charconv.version.pass.cpp | 84 ++++++++++++++++++++++ .../memory_resource.version.pass.cpp | 35 --------- .../utility.version.pass.cpp | 48 ------------- .../generate_feature_test_macro_components.py | 2 +- 6 files changed, 86 insertions(+), 118 deletions(-) delete mode 100644 libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp create mode 100644 libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp delete mode 100644 libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp diff --git a/libcxx/include/version b/libcxx/include/version index d2286f5..7c16ac8 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -149,7 +149,7 @@ __cpp_lib_syncbuf 201803L __cpp_lib_three_way_comparison 201907L __cpp_lib_to_address 201711L __cpp_lib_to_array 201907L -__cpp_lib_to_chars 201611L +__cpp_lib_to_chars 201611L __cpp_lib_to_underlying 202102L __cpp_lib_transformation_trait_aliases 201304L __cpp_lib_transparent_operators 201510L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp deleted file mode 100644 index 2afe2e2..0000000 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// feature macros - -/* Constant Value - __cpp_lib_to_chars 201611L - -*/ - -#include -#include -#include "test_macros.h" - -int main(int, char**) -{ -// ensure that the macros that are supposed to be defined in are defined. - -/* -#if !defined(__cpp_lib_fooby) -# error "__cpp_lib_fooby is not defined" -#elif __cpp_lib_fooby < 201606L -# error "__cpp_lib_fooby has an invalid value" -#endif -*/ - - return 0; -} diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp new file mode 100644 index 0000000..04818db --- /dev/null +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_feature_test_macro_components.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test the feature test macros defined by + +/* Constant Value + __cpp_lib_to_chars 201611L [C++17] +*/ + +#include +#include "test_macros.h" + +#if TEST_STD_VER < 14 + +# ifdef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should not be defined before c++17" +# endif + +#elif TEST_STD_VER == 14 + +# ifdef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should not be defined before c++17" +# endif + +#elif TEST_STD_VER == 17 + +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should be defined in c++17" +# endif +# if __cpp_lib_to_chars != 201611L +# error "__cpp_lib_to_chars should have the value 201611L in c++17" +# endif +# else // _LIBCPP_VERSION +# ifdef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!" +# endif +# endif + +#elif TEST_STD_VER == 20 + +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should be defined in c++20" +# endif +# if __cpp_lib_to_chars != 201611L +# error "__cpp_lib_to_chars should have the value 201611L in c++20" +# endif +# else // _LIBCPP_VERSION +# ifdef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!" +# endif +# endif + +#elif TEST_STD_VER > 20 + +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should be defined in c++2b" +# endif +# if __cpp_lib_to_chars != 201611L +# error "__cpp_lib_to_chars should have the value 201611L in c++2b" +# endif +# else // _LIBCPP_VERSION +# ifdef __cpp_lib_to_chars +# error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!" +# endif +# endif + +#endif // TEST_STD_VER > 20 + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp deleted file mode 100644 index d712a8b..0000000 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// feature macros - -/* Constant Value - __cpp_lib_memory_resource 201603L - -*/ - -// XFAIL -// #include -#include -#include "test_macros.h" - -int main(int, char**) -{ -// ensure that the macros that are supposed to be defined in are defined. - -/* -#if !defined(__cpp_lib_fooby) -# error "__cpp_lib_fooby is not defined" -#elif __cpp_lib_fooby < 201606L -# error "__cpp_lib_fooby has an invalid value" -#endif -*/ - - return 0; -} diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp index b5662f7..0159371 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp @@ -21,7 +21,6 @@ __cpp_lib_exchange_function 201304L [C++14] __cpp_lib_integer_comparison_functions 202002L [C++20] __cpp_lib_integer_sequence 201304L [C++14] - __cpp_lib_to_chars 201611L [C++17] __cpp_lib_to_underlying 202102L [C++2b] __cpp_lib_tuples_by_type 201304L [C++14] */ @@ -51,10 +50,6 @@ # error "__cpp_lib_integer_sequence should not be defined before c++14" # endif -# ifdef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should not be defined before c++17" -# endif - # ifdef __cpp_lib_to_underlying # error "__cpp_lib_to_underlying should not be defined before c++2b" # endif @@ -91,10 +86,6 @@ # error "__cpp_lib_integer_sequence should have the value 201304L in c++14" # endif -# ifdef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should not be defined before c++17" -# endif - # ifdef __cpp_lib_to_underlying # error "__cpp_lib_to_underlying should not be defined before c++2b" # endif @@ -137,19 +128,6 @@ # error "__cpp_lib_integer_sequence should have the value 201304L in c++17" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should be defined in c++17" -# endif -# if __cpp_lib_to_chars != 201611L -# error "__cpp_lib_to_chars should have the value 201611L in c++17" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!" -# endif -# endif - # ifdef __cpp_lib_to_underlying # error "__cpp_lib_to_underlying should not be defined before c++2b" # endif @@ -204,19 +182,6 @@ # error "__cpp_lib_integer_sequence should have the value 201304L in c++20" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should be defined in c++20" -# endif -# if __cpp_lib_to_chars != 201611L -# error "__cpp_lib_to_chars should have the value 201611L in c++20" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!" -# endif -# endif - # ifdef __cpp_lib_to_underlying # error "__cpp_lib_to_underlying should not be defined before c++2b" # endif @@ -271,19 +236,6 @@ # error "__cpp_lib_integer_sequence should have the value 201304L in c++2b" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should be defined in c++2b" -# endif -# if __cpp_lib_to_chars != 201611L -# error "__cpp_lib_to_chars should have the value 201611L in c++2b" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_to_chars -# error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!" -# endif -# endif - # ifndef __cpp_lib_to_underlying # error "__cpp_lib_to_underlying should be defined in c++2b" # endif diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 2e85893..1a78ace 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -596,7 +596,7 @@ feature_test_macros = [ add_version_header(x) for x in [ }, { "name": "__cpp_lib_to_chars", "values": { "c++17": 201611 }, - "headers": ["utility"], + "headers": ["charconv"], "unimplemented": True, }, { "name": "__cpp_lib_to_underlying", -- 2.7.4