[libcxx-commits] [libcxx] 98eb145 - [libc++] Require concepts support for <numbers>

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 19 07:49:54 PDT 2020


Author: Raul Tambre
Date: 2020-06-19T10:49:44-04:00
New Revision: 98eb1457ffbbd1511a151e2b88c1af4eb3ee4808

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

LOG: [libc++] Require concepts support for <numbers>

Similar to <concepts>, we need to protect the header and test against
inclusion and being run if concepts aren't supported by the compiler.

Differential Revision: https://reviews.llvm.org/D82171

Added: 
    

Modified: 
    libcxx/include/numbers
    libcxx/include/version
    libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
    libcxx/test/std/numerics/numbers/defined.pass.cpp
    libcxx/test/std/numerics/numbers/illformed.verify.cpp
    libcxx/test/std/numerics/numbers/specialize.pass.cpp
    libcxx/test/std/numerics/numbers/user_type.pass.cpp
    libcxx/test/std/numerics/numbers/value.pass.cpp
    libcxx/utils/generate_feature_test_macro_components.py

Removed: 
    


################################################################################
diff  --git a/libcxx/include/numbers b/libcxx/include/numbers
index cbf54cd156ef..e7d981be4aa4 100644
--- a/libcxx/include/numbers
+++ b/libcxx/include/numbers
@@ -60,7 +60,7 @@ namespace std::numbers {
 
 #include <__config>
 
-#if _LIBCPP_STD_VER > 17
+#if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
 
 #include <type_traits>
 #include <version>
@@ -136,6 +136,6 @@ _LIBCPP_END_NAMESPACE_STD
 
 _LIBCPP_POP_MACROS
 
-#endif //_LIBCPP_STD_VER > 17
+#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
 
 #endif // _LIBCPP_NUMBERS

diff  --git a/libcxx/include/version b/libcxx/include/version
index ee78e6cb1372..acedd03073cc 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -238,7 +238,9 @@ __cpp_lib_void_t                                        201411L <type_traits>
 #   define __cpp_lib_is_constant_evaluated              201811L
 # endif
 # define __cpp_lib_list_remove_return_type              201806L
-# define __cpp_lib_math_constants                       201907L
+# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
+#   define __cpp_lib_math_constants                     201907L
+# endif
 // # define __cpp_lib_ranges                               201811L
 # define __cpp_lib_span                                 202002L
 // # define __cpp_lib_three_way_comparison                 201711L

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp
index 9812b9ff0779..489b2178e2e9 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp
@@ -40,11 +40,17 @@
 
 #elif TEST_STD_VER > 17
 
-# ifndef __cpp_lib_math_constants
-#   error "__cpp_lib_math_constants should be defined in c++2a"
-# endif
-# if __cpp_lib_math_constants != 201907L
-#   error "__cpp_lib_math_constants should have the value 201907L in c++2a"
+# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
+#   ifndef __cpp_lib_math_constants
+#     error "__cpp_lib_math_constants should be defined in c++2a"
+#   endif
+#   if __cpp_lib_math_constants != 201907L
+#     error "__cpp_lib_math_constants should have the value 201907L in c++2a"
+#   endif
+# else
+#   ifdef __cpp_lib_math_constants
+#     error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!"
+#   endif
 # endif
 
 #endif // TEST_STD_VER > 17

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
index 9fcaa8b523d9..96a0fea6b918 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
@@ -1980,11 +1980,17 @@
 #   error "__cpp_lib_map_try_emplace should have the value 201411L in c++2a"
 # endif
 
-# ifndef __cpp_lib_math_constants
-#   error "__cpp_lib_math_constants should be defined in c++2a"
-# endif
-# if __cpp_lib_math_constants != 201907L
-#   error "__cpp_lib_math_constants should have the value 201907L in c++2a"
+# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
+#   ifndef __cpp_lib_math_constants
+#     error "__cpp_lib_math_constants should be defined in c++2a"
+#   endif
+#   if __cpp_lib_math_constants != 201907L
+#     error "__cpp_lib_math_constants should have the value 201907L in c++2a"
+#   endif
+# else
+#   ifdef __cpp_lib_math_constants
+#     error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!"
+#   endif
 # endif
 
 # if !defined(_LIBCPP_VERSION)

diff  --git a/libcxx/test/std/numerics/numbers/defined.pass.cpp b/libcxx/test/std/numerics/numbers/defined.pass.cpp
index 7cc2c1080452..cc8bf179a74e 100644
--- a/libcxx/test/std/numerics/numbers/defined.pass.cpp
+++ b/libcxx/test/std/numerics/numbers/defined.pass.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
 
 #include <numbers>
 

diff  --git a/libcxx/test/std/numerics/numbers/illformed.verify.cpp b/libcxx/test/std/numerics/numbers/illformed.verify.cpp
index 239ee1678756..5e35181f8fd9 100644
--- a/libcxx/test/std/numerics/numbers/illformed.verify.cpp
+++ b/libcxx/test/std/numerics/numbers/illformed.verify.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
 
 #include <numbers>
 

diff  --git a/libcxx/test/std/numerics/numbers/specialize.pass.cpp b/libcxx/test/std/numerics/numbers/specialize.pass.cpp
index db6f31c3aee3..380892cca4ea 100644
--- a/libcxx/test/std/numerics/numbers/specialize.pass.cpp
+++ b/libcxx/test/std/numerics/numbers/specialize.pass.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
 
 #include <cassert>
 #include <numbers>

diff  --git a/libcxx/test/std/numerics/numbers/user_type.pass.cpp b/libcxx/test/std/numerics/numbers/user_type.pass.cpp
index fd087086a08c..d4152c9ff74f 100644
--- a/libcxx/test/std/numerics/numbers/user_type.pass.cpp
+++ b/libcxx/test/std/numerics/numbers/user_type.pass.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
 
 #include <numbers>
 

diff  --git a/libcxx/test/std/numerics/numbers/value.pass.cpp b/libcxx/test/std/numerics/numbers/value.pass.cpp
index 1d2a67cb8a79..ff6a05ae2de3 100644
--- a/libcxx/test/std/numerics/numbers/value.pass.cpp
+++ b/libcxx/test/std/numerics/numbers/value.pass.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
 
 #include <cassert>
 #include <numbers>

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index dc4224885896..b77f88489d9d 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -604,6 +604,8 @@ def add_version_header(tc):
      "c++2a": int(201907),
    },
    "headers": ["numbers"],
+   "depends": "defined(__cpp_concepts) && __cpp_concepts >= 201811L",
+   "internal_depends": "defined(__cpp_concepts) && __cpp_concepts >= 201811L",
    },
 ]], key=lambda tc: tc["name"])
 


        


More information about the libcxx-commits mailing list