diff options
-rw-r--r-- | clang/docs/LanguageExtensions.rst | 14 | ||||
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 16 | ||||
-rw-r--r-- | clang/test/Lexer/cxx-features.cpp | 36 | ||||
-rw-r--r-- | clang/www/cxx_status.html | 17 |
4 files changed, 80 insertions, 3 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 865dd30bbeb..bf41ef5feaf 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -458,6 +458,13 @@ features are enabled. The ``__has_extension`` macro can be used to query if language features are available as an extension when compiling for a standard which does not provide them. The features which can be tested are listed here. +Since Clang 3.4, the C++ SD-6 feature test macros are also supported. +These are macros with names of the form ``__cpp_<feature_name>``, and are +intended to be a portable way to query the supported features of the compiler. +See `the C++ status page <http://clang.llvm.org/cxx_status.html#ts>`_ for +information on the version of SD-6 supported by each Clang release, and the +macros provided by that revision of the recommendations. + C++98 ----- @@ -751,6 +758,13 @@ Use ``__has_feature(cxx_aggregate_nsdmi)`` or ``__has_extension(cxx_aggregate_nsdmi)`` to determine if support for default initializers in aggregate members is enabled. +C++1y digit separators +^^^^^^^^^^^^^^^^^^^^^^ + +Use ``__cpp_digit_separators`` to determine if support for digit separators +using single quotes (for instance, ``10'000``) is enabled. At this time, there +is no corresponding ``__has_feature`` name + C++1y generalized lambda capture ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 476e214232f..75ac60f6b6d 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -409,6 +409,12 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI, /// ISO/IEC JTC1/SC22/WG21 (C++) SD-6: "SG10 Feature Test Recommendations". static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, MacroBuilder &Builder) { + // C++98 features. + if (LangOpts.RTTI) + Builder.defineMacro("__cpp_rtti", "199711"); + if (LangOpts.CXXExceptions) + Builder.defineMacro("__cpp_exceptions", "199711"); + // C++11 features. if (LangOpts.CPlusPlus11) { Builder.defineMacro("__cpp_unicode_characters", "200704"); @@ -418,16 +424,24 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_lambdas", "200907"); Builder.defineMacro("__cpp_constexpr", LangOpts.CPlusPlus14 ? "201304" : "200704"); + Builder.defineMacro("__cpp_range_based_for", "200907"); Builder.defineMacro("__cpp_static_assert", "200410"); Builder.defineMacro("__cpp_decltype", "200707"); Builder.defineMacro("__cpp_attributes", "200809"); Builder.defineMacro("__cpp_rvalue_references", "200610"); Builder.defineMacro("__cpp_variadic_templates", "200704"); + Builder.defineMacro("__cpp_initializer_lists", "200806"); + Builder.defineMacro("__cpp_delegating_constructors", "200604"); + Builder.defineMacro("__cpp_nsdmi", "200809"); + Builder.defineMacro("__cpp_inheriting_constructors", "200802"); + Builder.defineMacro("__cpp_ref_qualifiers", "200710"); + Builder.defineMacro("__cpp_alias_templates", "200704"); } // C++14 features. if (LangOpts.CPlusPlus14) { Builder.defineMacro("__cpp_binary_literals", "201304"); + Builder.defineMacro("__cpp_digit_separators", "201309"); Builder.defineMacro("__cpp_init_captures", "201304"); Builder.defineMacro("__cpp_generic_lambdas", "201304"); Builder.defineMacro("__cpp_decltype_auto", "201304"); @@ -435,6 +449,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_aggregate_nsdmi", "201304"); Builder.defineMacro("__cpp_variable_templates", "201304"); } + if (LangOpts.SizedDeallocation) + Builder.defineMacro("__cpp_sized_deallocation", "201309"); } static void InitializePredefinedMacros(const TargetInfo &TI, diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index 1202ecb1834..670a105aa40 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -16,6 +16,10 @@ #error "wrong value for __cpp_binary_literals" #endif +#if check(digit_separators, 0, 0, 201309) +#error "wrong value for __cpp_digit_separators" +#endif + #if check(init_captures, 0, 0, 201304) #error "wrong value for __cpp_init_captures" #endif @@ -24,6 +28,10 @@ #error "wrong value for __cpp_generic_lambdas" #endif +#if check(sized_deallocation, 0, 0, 201309) +#error "wrong value for __cpp_sized_deallocation" +#endif + #if check(constexpr, 0, 200704, 201304) #error "wrong value for __cpp_constexpr" #endif @@ -68,6 +76,10 @@ #error "wrong value for __cpp_lambdas" #endif +#if check(range_based_for, 0, 200907, 200907) +#error "wrong value for __cpp_range_based_for" +#endif + #if check(static_assert, 0, 200410, 200410) #error "wrong value for __cpp_static_assert" #endif @@ -87,3 +99,27 @@ #if check(variadic_templates, 0, 200704, 200704) #error "wrong value for __cpp_variadic_templates" #endif + +#if check(initializer_lists, 0, 200806, 200806) +#error "wrong value for __cpp_initializer_lists" +#endif + +#if check(delegating_constructors, 0, 200604, 200604) +#error "wrong value for __cpp_delegating_constructors" +#endif + +#if check(nsdmi, 0, 200809, 200809) +#error "wrong value for __cpp_nsdmi" +#endif + +#if check(inheriting_constructors, 0, 200802, 200802) +#error "wrong value for __cpp_inheriting_constructors" +#endif + +#if check(ref_qualifiers, 0, 200710, 200710) +#error "wrong value for __cpp_ref_qualifiers" +#endif + +#if check(alias_templates, 0, 200704, 200704) +#error "wrong value for __cpp_alias_templates" +#endif diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html index 1ba41064589..5239c2030bb 100644 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -583,9 +583,16 @@ Clang version they became available:</p> <th>Available in Clang?</th> </tr> <tr> - <td>SD-6: SG10 feature test recommendations</td> - <td><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td> - <td class="full" align="center">Clang 3.4 (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3745">N3745</a>)</td> + <td rowspan="2">SD-6: SG10 feature test recommendations</td> + <td rowspan="2"><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td> + <td class="full" align="center"> + Clang 3.4 (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3745">N3745</a>)</br> + </td> + </tr> + <tr> + <td class="partial" align="center"> + SVN (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4200">N4200</a>): Partial <a href="#n4200">(1)</a> + </td> </tr> <tr> <td>[DRAFT TS] Array extensions (arrays of runtime bound)</td> @@ -604,6 +611,10 @@ Clang version they became available:</p> </tr> </table> +<p> +<span id="n4200">(1): <code>__has_cpp_attribute</code> is not yet supported.</span> +</p> + </div> </body> </html> |