Author: Richard Smith Date: 2019-12-19T12:59:13-08:00 New Revision: df2e2ab07b48b81fb440e3522c6e639e8ef8f2e9
URL: https://github.com/llvm/llvm-project/commit/df2e2ab07b48b81fb440e3522c6e639e8ef8f2e9 DIFF: https://github.com/llvm/llvm-project/commit/df2e2ab07b48b81fb440e3522c6e639e8ef8f2e9.diff LOG: Implement latest C++ feature test macro recommendations. We don't yet advertise init capture packs, because I found some bugs while testing it. We reject-valid and then crash on both of these: template<int ...a> auto x = [...y = a] {}; template<int ...a> auto x = [y = a...] {}; Added: Modified: clang/lib/Frontend/InitPreprocessor.cpp clang/test/Lexer/cxx-features.cpp clang/www/cxx_status.html Removed: ################################################################################ diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 79360f89fc82..14c9ccd8a663 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -484,6 +484,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, LangOpts.CPlusPlus2a ? "201907L" : LangOpts.CPlusPlus17 ? "201603L" : LangOpts.CPlusPlus14 ? "201304L" : "200704"); + Builder.defineMacro("__cpp_constexpr_in_decltype", "201711L"); Builder.defineMacro("__cpp_range_based_for", LangOpts.CPlusPlus17 ? "201603L" : "200907"); Builder.defineMacro("__cpp_static_assert", @@ -506,8 +507,9 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, if (LangOpts.CPlusPlus14) { Builder.defineMacro("__cpp_binary_literals", "201304L"); Builder.defineMacro("__cpp_digit_separators", "201309L"); - Builder.defineMacro("__cpp_init_captures", "201304L"); - Builder.defineMacro("__cpp_generic_lambdas", "201304L"); + Builder.defineMacro("__cpp_init_captures", "201304L"); // (not latest) + Builder.defineMacro("__cpp_generic_lambdas", + LangOpts.CPlusPlus2a ? "201707L" : "201304L"); Builder.defineMacro("__cpp_decltype_auto", "201304L"); Builder.defineMacro("__cpp_return_type_deduction", "201304L"); Builder.defineMacro("__cpp_aggregate_nsdmi", "201304L"); @@ -523,7 +525,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_noexcept_function_type", "201510L"); Builder.defineMacro("__cpp_capture_star_this", "201603L"); Builder.defineMacro("__cpp_if_constexpr", "201606L"); - Builder.defineMacro("__cpp_deduction_guides", "201703L"); + Builder.defineMacro("__cpp_deduction_guides", "201703L"); // (not latest) Builder.defineMacro("__cpp_template_auto", "201606L"); // (old name) Builder.defineMacro("__cpp_namespace_attributes", "201411L"); Builder.defineMacro("__cpp_enumerator_attributes", "201411L"); @@ -531,7 +533,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_variadic_using", "201611L"); Builder.defineMacro("__cpp_aggregate_bases", "201603L"); Builder.defineMacro("__cpp_structured_bindings", "201606L"); - Builder.defineMacro("__cpp_nontype_template_args", "201411L"); + Builder.defineMacro("__cpp_nontype_template_args", + "201411L"); // (not latest) Builder.defineMacro("__cpp_fold_expressions", "201603L"); Builder.defineMacro("__cpp_guaranteed_copy_elision", "201606L"); Builder.defineMacro("__cpp_nontype_template_parameter_auto", "201606L"); @@ -543,10 +546,17 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, // C++20 features. if (LangOpts.CPlusPlus2a) { + //Builder.defineMacro("__cpp_aggregate_paren_init", "201902L"); + //Builder.defineMacro("__cpp_concepts", "201907L"); Builder.defineMacro("__cpp_conditional_explicit", "201806L"); + //Builder.defineMacro("__cpp_consteval", "201811L"); Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L"); Builder.defineMacro("__cpp_constinit", "201907L"); + //Builder.defineMacro("__cpp_coroutines", "201902L"); + Builder.defineMacro("__cpp_designated_initializers", "201707L"); Builder.defineMacro("__cpp_impl_three_way_comparison", "201907L"); + //Builder.defineMacro("__cpp_modules", "201907L"); + //Builder.defineMacro("__cpp_using_enum", "201907L"); } if (LangOpts.Char8) Builder.defineMacro("__cpp_char8_t", "201811L"); diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index 077f3155fee9..e771d891a14b 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -34,14 +34,30 @@ #error "wrong value for __cpp_char8_t" #endif +#if check(conditional_explicit, 0, 0, 0, 0, 201806) +#error "wrong value for __cpp_conditional_explicit" +#endif + +// constexpr checked below + #if check(constexpr_dynamic_alloc, 0, 0, 0, 0, 201907) #error "wrong value for __cpp_constexpr_dynamic_alloc" #endif +#if check(constexpr_in_decltype, 0, 201711, 201711, 201711, 201711) +#error "wrong value for __cpp_constexpr_in_decltype" +#endif + #if check(constinit, 0, 0, 0, 0, 201907) #error "wrong value for __cpp_constinit" #endif +#if check(designated_initializers, 0, 0, 0, 0, 201707) +#error "wrong value for __cpp_designated_initializers" +#endif + +// generic_lambdas checked below + #if check(impl_destroying_delete, 201806, 201806, 201806, 201806, 201806) #error "wrong value for __cpp_impl_destroying_delete" #endif @@ -158,7 +174,7 @@ #error "wrong value for __cpp_init_captures" #endif -#if check(generic_lambdas, 0, 0, 201304, 201304, 201304) +#if check(generic_lambdas, 0, 0, 201304, 201304, 201707) #error "wrong value for __cpp_generic_lambdas" #endif diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html index f46733e27a0f..6b181e7f8dbb 100755 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -1227,22 +1227,15 @@ <h2 id="ts">Technical specifications and standing documents</h2> </td> </tr> <tr> - <td class="partial" align="center"> - WIP (<a href="https://wg21.link/p1353r0">P1353R0</a>) - </td> - </tr> - <tr> - <td class="none" align="center"> - No (<a href="https://wg21.link/p1902r1">P1902R1</a>)</a> + <td class="full" align="center"> + Clang 9 (<a href="https://wg21.link/p1353r0">P1353R0</a>) </td> </tr> - <!-- FIXME: Implement latest recommendations. <tr> <td class="svn" align="center"> - SVN (<a href="https://wg21.link/p0096r3">P0096R3</a>)</a> + SVN (<a href="https://wg21.link/p1902r1">P1902R1</a>)</a> </td> </tr> - --> <!-- No compiler support is known to be needed for: * Concurrency TS * Parallelism TS (v1, v2) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits