[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

Cr-Mirrored-From: https://chromium.googlesource.com/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 98eb1457ffbbd1511a151e2b88c1af4eb3ee4808
diff --git a/include/numbers b/include/numbers
index cbf54cd..e7d981b 100644
--- a/include/numbers
+++ b/include/numbers
@@ -60,7 +60,7 @@
 
 #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_POP_MACROS
 
-#endif //_LIBCPP_STD_VER > 17
+#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
 
 #endif // _LIBCPP_NUMBERS
diff --git a/include/version b/include/version
index ee78e6c..acedd03 100644
--- a/include/version
+++ b/include/version
@@ -238,7 +238,9 @@
 #   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/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp b/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp
index 9812b9f..489b217 100644
--- a/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp
+++ b/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/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
index 9fcaa8b..96a0fea 100644
--- a/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
+++ b/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/test/std/numerics/numbers/defined.pass.cpp b/test/std/numerics/numbers/defined.pass.cpp
index 7cc2c10..cc8bf17 100644
--- a/test/std/numerics/numbers/defined.pass.cpp
+++ b/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/test/std/numerics/numbers/illformed.verify.cpp b/test/std/numerics/numbers/illformed.verify.cpp
index 239ee16..5e35181 100644
--- a/test/std/numerics/numbers/illformed.verify.cpp
+++ b/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/test/std/numerics/numbers/specialize.pass.cpp b/test/std/numerics/numbers/specialize.pass.cpp
index db6f31c..380892c 100644
--- a/test/std/numerics/numbers/specialize.pass.cpp
+++ b/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/test/std/numerics/numbers/user_type.pass.cpp b/test/std/numerics/numbers/user_type.pass.cpp
index fd08708..d4152c9 100644
--- a/test/std/numerics/numbers/user_type.pass.cpp
+++ b/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/test/std/numerics/numbers/value.pass.cpp b/test/std/numerics/numbers/value.pass.cpp
index 1d2a67c..ff6a05a 100644
--- a/test/std/numerics/numbers/value.pass.cpp
+++ b/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/utils/generate_feature_test_macro_components.py b/utils/generate_feature_test_macro_components.py
index dc42248..b77f884 100755
--- a/utils/generate_feature_test_macro_components.py
+++ b/utils/generate_feature_test_macro_components.py
@@ -604,6 +604,8 @@
      "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"])