forked from OSchip/llvm-project
P0096R5, P0941R2: Update to match latest feature test macro specification.
llvm-svn: 334677
This commit is contained in:
parent
cb0d20519e
commit
20eb9baa6d
|
@ -487,82 +487,86 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
|
|||
MacroBuilder &Builder) {
|
||||
// C++98 features.
|
||||
if (LangOpts.RTTI)
|
||||
Builder.defineMacro("__cpp_rtti", "199711");
|
||||
Builder.defineMacro("__cpp_rtti", "199711L");
|
||||
if (LangOpts.CXXExceptions)
|
||||
Builder.defineMacro("__cpp_exceptions", "199711");
|
||||
Builder.defineMacro("__cpp_exceptions", "199711L");
|
||||
|
||||
// C++11 features.
|
||||
if (LangOpts.CPlusPlus11) {
|
||||
Builder.defineMacro("__cpp_unicode_characters", "200704");
|
||||
Builder.defineMacro("__cpp_raw_strings", "200710");
|
||||
Builder.defineMacro("__cpp_unicode_literals", "200710");
|
||||
Builder.defineMacro("__cpp_user_defined_literals", "200809");
|
||||
Builder.defineMacro("__cpp_lambdas", "200907");
|
||||
Builder.defineMacro("__cpp_unicode_characters", "200704L");
|
||||
Builder.defineMacro("__cpp_raw_strings", "200710L");
|
||||
Builder.defineMacro("__cpp_unicode_literals", "200710L");
|
||||
Builder.defineMacro("__cpp_user_defined_literals", "200809L");
|
||||
Builder.defineMacro("__cpp_lambdas", "200907L");
|
||||
Builder.defineMacro("__cpp_constexpr",
|
||||
LangOpts.CPlusPlus17 ? "201603" :
|
||||
LangOpts.CPlusPlus14 ? "201304" : "200704");
|
||||
LangOpts.CPlusPlus17 ? "201603L" :
|
||||
LangOpts.CPlusPlus14 ? "201304L" : "200704");
|
||||
Builder.defineMacro("__cpp_range_based_for",
|
||||
LangOpts.CPlusPlus17 ? "201603" : "200907");
|
||||
LangOpts.CPlusPlus17 ? "201603L" : "200907");
|
||||
Builder.defineMacro("__cpp_static_assert",
|
||||
LangOpts.CPlusPlus17 ? "201411" : "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", "201511");
|
||||
Builder.defineMacro("__cpp_ref_qualifiers", "200710");
|
||||
Builder.defineMacro("__cpp_alias_templates", "200704");
|
||||
LangOpts.CPlusPlus17 ? "201411L" : "200410");
|
||||
Builder.defineMacro("__cpp_decltype", "200707L");
|
||||
Builder.defineMacro("__cpp_attributes", "200809L");
|
||||
Builder.defineMacro("__cpp_rvalue_references", "200610L");
|
||||
Builder.defineMacro("__cpp_variadic_templates", "200704L");
|
||||
Builder.defineMacro("__cpp_initializer_lists", "200806L");
|
||||
Builder.defineMacro("__cpp_delegating_constructors", "200604L");
|
||||
Builder.defineMacro("__cpp_nsdmi", "200809L");
|
||||
Builder.defineMacro("__cpp_inheriting_constructors", "201511L");
|
||||
Builder.defineMacro("__cpp_ref_qualifiers", "200710L");
|
||||
Builder.defineMacro("__cpp_alias_templates", "200704L");
|
||||
}
|
||||
if (LangOpts.ThreadsafeStatics)
|
||||
Builder.defineMacro("__cpp_threadsafe_static_init", "200806");
|
||||
Builder.defineMacro("__cpp_threadsafe_static_init", "200806L");
|
||||
|
||||
// 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");
|
||||
Builder.defineMacro("__cpp_return_type_deduction", "201304");
|
||||
Builder.defineMacro("__cpp_aggregate_nsdmi", "201304");
|
||||
Builder.defineMacro("__cpp_variable_templates", "201304");
|
||||
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_decltype_auto", "201304L");
|
||||
Builder.defineMacro("__cpp_return_type_deduction", "201304L");
|
||||
Builder.defineMacro("__cpp_aggregate_nsdmi", "201304L");
|
||||
Builder.defineMacro("__cpp_variable_templates", "201304L");
|
||||
}
|
||||
if (LangOpts.SizedDeallocation)
|
||||
Builder.defineMacro("__cpp_sized_deallocation", "201309");
|
||||
Builder.defineMacro("__cpp_sized_deallocation", "201309L");
|
||||
|
||||
// C++17 features.
|
||||
if (LangOpts.CPlusPlus17) {
|
||||
Builder.defineMacro("__cpp_hex_float", "201603");
|
||||
Builder.defineMacro("__cpp_inline_variables", "201606");
|
||||
Builder.defineMacro("__cpp_noexcept_function_type", "201510");
|
||||
Builder.defineMacro("__cpp_capture_star_this", "201603");
|
||||
Builder.defineMacro("__cpp_if_constexpr", "201606");
|
||||
Builder.defineMacro("__cpp_deduction_guides", "201703");
|
||||
Builder.defineMacro("__cpp_template_auto", "201606");
|
||||
Builder.defineMacro("__cpp_namespace_attributes", "201411");
|
||||
Builder.defineMacro("__cpp_enumerator_attributes", "201411");
|
||||
Builder.defineMacro("__cpp_nested_namespace_definitions", "201411");
|
||||
Builder.defineMacro("__cpp_variadic_using", "201611");
|
||||
Builder.defineMacro("__cpp_aggregate_bases", "201603");
|
||||
Builder.defineMacro("__cpp_structured_bindings", "201606");
|
||||
Builder.defineMacro("__cpp_nontype_template_args", "201411");
|
||||
Builder.defineMacro("__cpp_fold_expressions", "201603");
|
||||
Builder.defineMacro("__cpp_hex_float", "201603L");
|
||||
Builder.defineMacro("__cpp_inline_variables", "201606L");
|
||||
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_template_auto", "201606L"); // (old name)
|
||||
Builder.defineMacro("__cpp_namespace_attributes", "201411L");
|
||||
Builder.defineMacro("__cpp_enumerator_attributes", "201411L");
|
||||
Builder.defineMacro("__cpp_nested_namespace_definitions", "201411L");
|
||||
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_fold_expressions", "201603L");
|
||||
Builder.defineMacro("__cpp_guaranteed_copy_elision", "201606L");
|
||||
Builder.defineMacro("__cpp_nontype_template_parameter_auto", "201606L");
|
||||
}
|
||||
if (LangOpts.AlignedAllocation)
|
||||
Builder.defineMacro("__cpp_aligned_new", "201606");
|
||||
Builder.defineMacro("__cpp_aligned_new", "201606L");
|
||||
if (LangOpts.RelaxedTemplateTemplateArgs)
|
||||
Builder.defineMacro("__cpp_template_template_args", "201611L");
|
||||
|
||||
// TS features.
|
||||
if (LangOpts.ConceptsTS)
|
||||
Builder.defineMacro("__cpp_experimental_concepts", "1");
|
||||
Builder.defineMacro("__cpp_experimental_concepts", "1L");
|
||||
if (LangOpts.CoroutinesTS)
|
||||
Builder.defineMacro("__cpp_coroutines", "201703L");
|
||||
|
||||
// Potential future breaking changes.
|
||||
if (LangOpts.Char8)
|
||||
Builder.defineMacro("__cpp_char8_t", "201803");
|
||||
Builder.defineMacro("__cpp_char8_t", "201803L");
|
||||
}
|
||||
|
||||
static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// RUN: %clang_cc1 -std=c++98 -fcxx-exceptions -verify %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -verify %s
|
||||
// RUN: %clang_cc1 -std=c++1y -fcxx-exceptions -fsized-deallocation -verify %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s
|
||||
// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -verify %s
|
||||
// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
|
||||
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -verify %s
|
||||
// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fsized-deallocation -verify %s
|
||||
//
|
||||
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
|
||||
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
|
||||
// RUN: %clang_cc1 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
|
||||
// RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
|
||||
// RUN: %clang_cc1 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
|
||||
|
@ -12,13 +14,13 @@
|
|||
|
||||
// FIXME using `defined` in a macro has undefined behavior.
|
||||
#if __cplusplus < 201103L
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
|
||||
#elif __cplusplus < 201402L
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
|
||||
#elif __cplusplus < 201406L
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
|
||||
#else
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
|
||||
#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx17 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17
|
||||
#endif
|
||||
|
||||
// --- C++17 features ---
|
||||
|
@ -35,6 +37,10 @@
|
|||
#error "wrong value for __cpp_aligned_new"
|
||||
#endif
|
||||
|
||||
#if check(guaranteed_copy_elision, 0, 0, 0, 201606)
|
||||
#error "wrong value for __cpp_guaranteed_copy_elision"
|
||||
#endif
|
||||
|
||||
#if check(noexcept_function_type, 0, 0, 0, 201510)
|
||||
#error "wrong value for __cpp_noexcept_function_type"
|
||||
#endif
|
||||
|
@ -61,6 +67,12 @@
|
|||
#error "wrong value for __cpp_deduction_guides"
|
||||
#endif
|
||||
|
||||
#if check(nontype_template_parameter_auto, 0, 0, 0, 201606)
|
||||
#error "wrong value for __cpp_nontype_template_parameter_auto"
|
||||
#endif
|
||||
|
||||
// This is the old name (from P0096R4) for
|
||||
// __cpp_nontype_template_parameter_auto
|
||||
#if check(template_auto, 0, 0, 0, 201606)
|
||||
#error "wrong value for __cpp_template_auto"
|
||||
#endif
|
||||
|
@ -75,6 +87,7 @@
|
|||
#error "wrong value for __cpp_enumerator_attributes"
|
||||
#endif
|
||||
|
||||
// This is an old name (from P0096R4), now removed from SD-6.
|
||||
#if check(nested_namespace_definitions, 0, 0, 0, 201411)
|
||||
#error "wrong value for __cpp_nested_namespace_definitions"
|
||||
#endif
|
||||
|
@ -97,7 +110,9 @@
|
|||
#error "wrong value for __cpp_nontype_template_args"
|
||||
#endif
|
||||
|
||||
#if check(template_template_args, 0, 0, 0, 0) // FIXME: should be 201611 when feature is enabled
|
||||
#if defined(RELAXED_TEMPLATE_TEMPLATE_ARGS) \
|
||||
? check(template_template_args, 0, 0, 0, 201611) \
|
||||
: check(template_template_args, 0, 0, 0, 0)
|
||||
#error "wrong value for __cpp_template_template_args"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -962,7 +962,7 @@ as the draft C++2a standard evolves.
|
|||
<tr>
|
||||
<td>Feature test macros</td>
|
||||
<td><a href="http://wg21.link/p0941r2">P0941R2</a></td>
|
||||
<td class="na" align="center"><a href="#sd6">(see below)</a></td>
|
||||
<td class="full" align="center"><a href="#sd6">(see below)</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>explicit(bool)</tt></td>
|
||||
|
@ -1002,9 +1002,9 @@ and library features that are not part of standard C++.</p>
|
|||
<th>Available in Clang?</th>
|
||||
</tr>
|
||||
<tr id="sd6">
|
||||
<td rowspan="4">SD-6: SG10 feature test recommendations</td>
|
||||
<td rowspan="4"><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td>
|
||||
<td rowspan="4">N/A</td>
|
||||
<td rowspan="5">SD-6: SG10 feature test recommendations</td>
|
||||
<td rowspan="5"><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td>
|
||||
<td rowspan="5">N/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>
|
||||
|
@ -1024,6 +1024,11 @@ and library features that are not part of standard C++.</p>
|
|||
Clang 5 (<a href="http://wg21.link/p0096r4">P0096R4</a>)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="svn" align="center">
|
||||
SVN (<a href="http://wg21.link/p0096r5">P0096R5</a>)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- FIXME: Implement latest recommendations.
|
||||
<tr>
|
||||
<td class="svn" align="center">
|
||||
|
@ -1033,7 +1038,7 @@ and library features that are not part of standard C++.</p>
|
|||
-->
|
||||
<!-- No compiler support is known to be needed for:
|
||||
* Concurrency TS
|
||||
* Parallelism TS
|
||||
* Parallelism TS (v1, v2)
|
||||
* Ranges TS
|
||||
* Networking TS
|
||||
* File System TS
|
||||
|
@ -1058,20 +1063,20 @@ and library features that are not part of standard C++.</p>
|
|||
<td class="none" align="center">No</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[DRAFT TS] Library Fundamentals, Version 2 (<tt>source_location</tt>)</td>
|
||||
<td><a href="http://wg21.link/n4600">N4600</a></td>
|
||||
<td>[TS] Library Fundamentals, Version 2 (<tt>source_location</tt>)</td>
|
||||
<td><a href="http://wg21.link/n4617">N4617</a></td>
|
||||
<td>N/A</td>
|
||||
<td class="none" align="center">No</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[DRAFT TS] Modules</td>
|
||||
<td><a href="http://wg21.link/n4667">N4667</a></td>
|
||||
<td>[TS] Modules</td>
|
||||
<td><a href="http://wg21.link/n4720">N4720</a></td>
|
||||
<td><tt>-fmodules-ts</tt></td>
|
||||
<td class="none" align="center">WIP</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[DRAFT TS] Reflection</td>
|
||||
<td><a href="http://wg21.link/p0194r6">P0194R6</a></td>
|
||||
<td><a href="http://wg21.link/n4746">N4746</a></td>
|
||||
<td></td>
|
||||
<td class="none" align="center">No</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue