[libcxx-commits] [libcxx] c36961b - [libc++] Adds __cpp_lib_three_way_comparison FTM. (#91515)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 12 09:59:25 PDT 2024


Author: Mark de Wever
Date: 2024-06-12T18:59:21+02:00
New Revision: c36961bd96583f0d63b78030bd5587b84b1d6cee

URL: https://github.com/llvm/llvm-project/commit/c36961bd96583f0d63b78030bd5587b84b1d6cee
DIFF: https://github.com/llvm/llvm-project/commit/c36961bd96583f0d63b78030bd5587b84b1d6cee.diff

LOG: [libc++] Adds __cpp_lib_three_way_comparison FTM. (#91515)

The paper
  P0768R1 Library Support for the Spaceship (Comparison) Operator
did not add a feature-test macro. This omission has been corrected in
  P1353R0 Missing Feature Test Macros

This enables the FTM for P0768R1

Fixes: https://github.com/llvm/llvm-project/issues/73953

---------

Co-authored-by: S. B. Tam <cpplearner at outlook.com>

Added: 
    

Modified: 
    libcxx/docs/FeatureTestMacroTable.rst
    libcxx/docs/Status/Cxx20Papers.csv
    libcxx/include/version
    libcxx/test/std/language.support/support.limits/support.limits.general/compare.version.compile.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
    libcxx/utils/generate_feature_test_macro_components.py

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 0297068785e8b..1e706a542eaf2 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -290,7 +290,7 @@ Status
     ---------------------------------------------------------- -----------------
     ``__cpp_lib_syncbuf``                                      ``201803L``
     ---------------------------------------------------------- -----------------
-    ``__cpp_lib_three_way_comparison``                         *unimplemented*
+    ``__cpp_lib_three_way_comparison``                         ``201711L``
     ---------------------------------------------------------- -----------------
     ``__cpp_lib_to_address``                                   ``201711L``
     ---------------------------------------------------------- -----------------

diff  --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index 462c7eff55d58..34fc5586f74d9 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -78,7 +78,7 @@
 "`P1236R1 <https://wg21.link/P1236R1>`__","CWG","Alternative Wording for P0907R4 Signed Integers are Two's Complement","San Diego","* *",""
 "`P1248R1 <https://wg21.link/P1248R1>`__","LWG","Remove CommonReference requirement from StrictWeakOrdering (a.k.a Fixing Relations)","San Diego","|Complete|","13.0"
 "`P1285R0 <https://wg21.link/P1285R0>`__","LWG","Improving Completeness Requirements for Type Traits","San Diego","* *",""
-"`P1353R0 <https://wg21.link/P1353R0>`__","CWG","Missing feature test macros","San Diego","* *",""
+"`P1353R0 <https://wg21.link/P1353R0>`__","CWG","Missing feature test macros","San Diego","|In Progress|",""
 "","","","","","",""
 "`P0339R6 <https://wg21.link/P0339R6>`__","LWG","polymorphic_allocator<> as a vocabulary type","Kona","|Complete|","16.0"
 "`P0340R3 <https://wg21.link/P0340R3>`__","LWG","Making std::underlying_type SFINAE-friendly","Kona","|Complete|","9.0"

diff  --git a/libcxx/include/version b/libcxx/include/version
index d433e1b1c9cea..68e0e6c3ab84e 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -229,7 +229,7 @@ __cpp_lib_string_view                                   201803L <string> <string
 __cpp_lib_submdspan                                     202306L <mdspan>
 __cpp_lib_syncbuf                                       201803L <syncstream>
 __cpp_lib_text_encoding                                 202306L <text_encoding>
-__cpp_lib_three_way_comparison                          201907L <compare>
+__cpp_lib_three_way_comparison                          201711L <compare>
 __cpp_lib_to_address                                    201711L <memory>
 __cpp_lib_to_array                                      201907L <array>
 __cpp_lib_to_chars                                      202306L <charconv>
@@ -437,7 +437,7 @@ __cpp_lib_void_t                                        201411L <type_traits>
 # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
 #   define __cpp_lib_syncbuf                            201803L
 # endif
-// # define __cpp_lib_three_way_comparison                 201907L
+# define __cpp_lib_three_way_comparison                 201711L
 # define __cpp_lib_to_address                           201711L
 # define __cpp_lib_to_array                             201907L
 # define __cpp_lib_type_identity                        201806L

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/compare.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/compare.version.compile.pass.cpp
index f521c53250b63..aac00f20c7b45 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/compare.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/compare.version.compile.pass.cpp
@@ -16,7 +16,7 @@
 // Test the feature test macros defined by <compare>
 
 /*  Constant                          Value
-    __cpp_lib_three_way_comparison    201907L [C++20]
+    __cpp_lib_three_way_comparison    201711L [C++20]
 */
 
 #include <compare>
@@ -42,47 +42,29 @@
 
 #elif TEST_STD_VER == 20
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should be defined in c++20"
-#   endif
-#   if __cpp_lib_three_way_comparison != 201907L
-#     error "__cpp_lib_three_way_comparison should have the value 201907L in c++20"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_three_way_comparison
+#   error "__cpp_lib_three_way_comparison should be defined in c++20"
+# endif
+# if __cpp_lib_three_way_comparison != 201711L
+#   error "__cpp_lib_three_way_comparison should have the value 201711L in c++20"
 # endif
 
 #elif TEST_STD_VER == 23
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should be defined in c++23"
-#   endif
-#   if __cpp_lib_three_way_comparison != 201907L
-#     error "__cpp_lib_three_way_comparison should have the value 201907L in c++23"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_three_way_comparison
+#   error "__cpp_lib_three_way_comparison should be defined in c++23"
+# endif
+# if __cpp_lib_three_way_comparison != 201711L
+#   error "__cpp_lib_three_way_comparison should have the value 201711L in c++23"
 # endif
 
 #elif TEST_STD_VER > 23
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should be defined in c++26"
-#   endif
-#   if __cpp_lib_three_way_comparison != 201907L
-#     error "__cpp_lib_three_way_comparison should have the value 201907L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_three_way_comparison
+#   error "__cpp_lib_three_way_comparison should be defined in c++26"
+# endif
+# if __cpp_lib_three_way_comparison != 201711L
+#   error "__cpp_lib_three_way_comparison should have the value 201711L in c++26"
 # endif
 
 #endif // TEST_STD_VER > 23

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index c1e1f9f340af4..b882fe4f047b3 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -211,7 +211,7 @@
     __cpp_lib_submdspan                                     202306L [C++26]
     __cpp_lib_syncbuf                                       201803L [C++20]
     __cpp_lib_text_encoding                                 202306L [C++26]
-    __cpp_lib_three_way_comparison                          201907L [C++20]
+    __cpp_lib_three_way_comparison                          201711L [C++20]
     __cpp_lib_to_address                                    201711L [C++20]
     __cpp_lib_to_array                                      201907L [C++20]
     __cpp_lib_to_chars                                      201611L [C++17]
@@ -4309,17 +4309,11 @@
 #   error "__cpp_lib_text_encoding should not be defined before c++26"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should be defined in c++20"
-#   endif
-#   if __cpp_lib_three_way_comparison != 201907L
-#     error "__cpp_lib_three_way_comparison should have the value 201907L in c++20"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_three_way_comparison
+#   error "__cpp_lib_three_way_comparison should be defined in c++20"
+# endif
+# if __cpp_lib_three_way_comparison != 201711L
+#   error "__cpp_lib_three_way_comparison should have the value 201711L in c++20"
 # endif
 
 # ifndef __cpp_lib_to_address
@@ -5894,17 +5888,11 @@
 #   error "__cpp_lib_text_encoding should not be defined before c++26"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should be defined in c++23"
-#   endif
-#   if __cpp_lib_three_way_comparison != 201907L
-#     error "__cpp_lib_three_way_comparison should have the value 201907L in c++23"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_three_way_comparison
+#   error "__cpp_lib_three_way_comparison should be defined in c++23"
+# endif
+# if __cpp_lib_three_way_comparison != 201711L
+#   error "__cpp_lib_three_way_comparison should have the value 201711L in c++23"
 # endif
 
 # ifndef __cpp_lib_to_address
@@ -7749,17 +7737,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should be defined in c++26"
-#   endif
-#   if __cpp_lib_three_way_comparison != 201907L
-#     error "__cpp_lib_three_way_comparison should have the value 201907L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_three_way_comparison
-#     error "__cpp_lib_three_way_comparison should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_three_way_comparison
+#   error "__cpp_lib_three_way_comparison should be defined in c++26"
+# endif
+# if __cpp_lib_three_way_comparison != 201711L
+#   error "__cpp_lib_three_way_comparison should have the value 201711L in c++26"
 # endif
 
 # ifndef __cpp_lib_to_address

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 490ecefc97522..54206fb0c9bbf 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1246,9 +1246,9 @@ def add_version_header(tc):
         },
         {
             "name": "__cpp_lib_three_way_comparison",
-            "values": {"c++20": 201907},
+            "values": {"c++20": 201711},
+            # {"c++20": 201907} # P1614R2 The Mothership has Landed (see P1902R1 Missing feature-test macros 2017-2019)
             "headers": ["compare"],
-            "unimplemented": True,
         },
         {
             "name": "__cpp_lib_to_address",


        


More information about the libcxx-commits mailing list