From 98eb1457ffbbd1511a151e2b88c1af4eb3ee4808 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Fri, 19 Jun 2020 10:36:44 -0400 Subject: [PATCH] [libc++] Require concepts support for Similar to , 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 --- libcxx/include/numbers | 4 ++-- libcxx/include/version | 4 +++- .../numbers.version.pass.cpp | 16 +++++++++++----- .../version.version.pass.cpp | 16 +++++++++++----- .../test/std/numerics/numbers/defined.pass.cpp | 1 + .../std/numerics/numbers/illformed.verify.cpp | 1 + .../std/numerics/numbers/specialize.pass.cpp | 1 + .../test/std/numerics/numbers/user_type.pass.cpp | 1 + libcxx/test/std/numerics/numbers/value.pass.cpp | 1 + .../generate_feature_test_macro_components.py | 2 ++ 10 files changed, 34 insertions(+), 13 deletions(-) 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 #include @@ -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 # 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 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 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 #include 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 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 #include 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 @@ feature_test_macros = sorted([ add_version_header(x) for x in [ "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"])