]> granicus.if.org Git - clang/commitdiff
Update Clang's SD-6 support to match N4200 (except for __has_cpp_attribute,
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Nov 2014 21:16:38 +0000 (21:16 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Nov 2014 21:16:38 +0000 (21:16 +0000)
which we don't yet implement).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221816 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LanguageExtensions.rst
lib/Frontend/InitPreprocessor.cpp
test/Lexer/cxx-features.cpp
www/cxx_status.html

index 865dd30bbeb520c9552acaec4f1e81ecf523ae53..bf41ef5feaf257455eb0bcb85cf6e531657e057e 100644 (file)
@@ -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
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
index 476e214232f539ea975c071e078ddb6c41b97ad6..75ac60f6b6d41f4390d406334313e2b32abccc14 100644 (file)
@@ -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,
index 1202ecb1834918d248771ef319d764a48e813ef4..670a105aa40cfc99ac9fb2e970f4f6929a68b3a4 100644 (file)
 #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
 #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
 #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
 #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
index 1ba41064589943ba6502559fa21756a1b7ad872b..5239c2030bbfa193d5f5dfd0491c7acf8749051c 100644 (file)
@@ -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>