r282622 - P0096R2: Implement more recent revision of SD-6 (C++ feature test macros).

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 28 12:44:50 PDT 2016


Author: rsmith
Date: Wed Sep 28 14:44:50 2016
New Revision: 282622

URL: http://llvm.org/viewvc/llvm-project?rev=282622&view=rev
Log:
P0096R2: Implement more recent revision of SD-6 (C++ feature test macros).

Modified:
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/Lexer/cxx-features.cpp
    cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=282622&r1=282621&r2=282622&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Sep 28 14:44:50 2016
@@ -468,7 +468,8 @@ static void InitializeCPlusPlusFeatureTe
     Builder.defineMacro("__cpp_constexpr",
                         LangOpts.CPlusPlus14 ? "201304" : "200704");
     Builder.defineMacro("__cpp_range_based_for", "200907");
-    Builder.defineMacro("__cpp_static_assert", "200410");
+    Builder.defineMacro("__cpp_static_assert",
+                        LangOpts.CPlusPlus1z ? "201411" : "200410");
     Builder.defineMacro("__cpp_decltype", "200707");
     Builder.defineMacro("__cpp_attributes", "200809");
     Builder.defineMacro("__cpp_rvalue_references", "200610");
@@ -476,7 +477,7 @@ static void InitializeCPlusPlusFeatureTe
     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_inheriting_constructors", "201511");
     Builder.defineMacro("__cpp_ref_qualifiers", "200710");
     Builder.defineMacro("__cpp_alias_templates", "200704");
   }
@@ -494,6 +495,18 @@ static void InitializeCPlusPlusFeatureTe
   }
   if (LangOpts.SizedDeallocation)
     Builder.defineMacro("__cpp_sized_deallocation", "201309");
+
+  // C++17 features.
+  if (LangOpts.CPlusPlus1z) {
+    //Builder.defineMacro("__cpp_noexcept_function_type", "201510");
+    Builder.defineMacro("__cpp_fold_expressions", "201411");
+    Builder.defineMacro("__cpp_namespace_attributes", "201411");
+    Builder.defineMacro("__cpp_enumerator_attributes", "201411");
+    Builder.defineMacro("__cpp_nested_namespace_definitions", "201411");
+    Builder.defineMacro("__cpp_nontype_template_args", "201411");
+  }
+
+  // TS features.
   if (LangOpts.ConceptsTS)
     Builder.defineMacro("__cpp_experimental_concepts", "1");
   if (LangOpts.Coroutines)

Modified: cfe/trunk/test/Lexer/cxx-features.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=282622&r1=282621&r2=282622&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)
+++ cfe/trunk/test/Lexer/cxx-features.cpp Wed Sep 28 14:44:50 2016
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -std=c++98 -verify %s
-// RUN: %clang_cc1 -std=c++11 -verify %s
-// RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s
-// RUN: %clang_cc1 -std=c++14 -fsized-deallocation -verify %s
-// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s
-// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
-// RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s
+// 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 -fno-rtti -verify %s -DNO_EXCEPTIONS -DNO_RTTI
+// RUN: %clang_cc1 -fcoroutines -DNO_EXCEPTIONS -DCOROUTINES -verify %s
 
 // expected-no-diagnostics
 
@@ -19,10 +20,44 @@
 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
 #endif
 
+// --- C++17 features ---
+
+#if check(noexcept_function_type, 0, 0, 0, 0)
+// FIXME
+#error "wrong value for __cpp_noexcept_function_type"
+#endif
+
+#if check(fold_expressions, 0, 0, 0, 201411)
+#error "wrong value for __cpp_fold_expressions"
+#endif
+
+// static_assert checked below
+
+#if check(namespace_attributes, 0, 0, 0, 201411)
+// FIXME: allowed without warning in C++14 and C++11
+#error "wrong value for __cpp_namespace_attributes"
+#endif
+
+#if check(enumerator_attributes, 0, 0, 0, 201411)
+// FIXME: allowed without warning in C++14 and C++11
+#error "wrong value for __cpp_enumerator_attributes"
+#endif
+
+#if check(nested_namespace_definitions, 0, 0, 0, 201411)
+#error "wrong value for __cpp_nested_namespace_definitions"
+#endif
+
+#if check(nontype_template_args, 0, 0, 0, 201411)
+#error "wrong value for __cpp_nontype_template_args"
+#endif
+
+// --- C++14 features ---
+
 #if check(binary_literals, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_binary_literals"
 #endif
 
+// (Removed from SD-6.)
 #if check(digit_separators, 0, 0, 201309, 201309)
 #error "wrong value for __cpp_digit_separators"
 #endif
@@ -39,9 +74,7 @@
 #error "wrong value for __cpp_sized_deallocation"
 #endif
 
-#if check(constexpr, 0, 200704, 201304, 201304)
-#error "wrong value for __cpp_constexpr"
-#endif
+// constexpr checked below
 
 #if check(decltype_auto, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_decltype_auto"
@@ -63,6 +96,8 @@
 #error "wrong value for __cpp_variable_templates"
 #endif
 
+// --- C++11 features ---
+
 #if check(unicode_characters, 0, 200704, 200704, 200704)
 #error "wrong value for __cpp_unicode_characters"
 #endif
@@ -83,11 +118,15 @@
 #error "wrong value for __cpp_lambdas"
 #endif
 
+#if check(constexpr, 0, 200704, 201304, 201304)
+#error "wrong value for __cpp_constexpr"
+#endif
+
 #if check(range_based_for, 0, 200907, 200907, 200907)
 #error "wrong value for __cpp_range_based_for"
 #endif
 
-#if check(static_assert, 0, 200410, 200410, 200410)
+#if check(static_assert, 0, 200410, 200410, 201411)
 #error "wrong value for __cpp_static_assert"
 #endif
 
@@ -119,7 +158,7 @@
 #error "wrong value for __cpp_nsdmi"
 #endif
 
-#if check(inheriting_constructors, 0, 200802, 200802, 200802)
+#if check(inheriting_constructors, 0, 201511, 201511, 201511)
 #error "wrong value for __cpp_inheriting_constructors"
 #endif
 
@@ -131,6 +170,18 @@
 #error "wrong value for __cpp_alias_templates"
 #endif
 
+// --- C++98 features ---
+
+#if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
+#error "wrong value for __cpp_rtti"
+#endif
+
+#if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
+#error "wrong value for __cpp_exceptions"
+#endif
+
+// --- TS features --
+
 #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
 #error "wrong value for __cpp_experimental_concepts"
 #endif

Modified: cfe/trunk/www/cxx_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=282622&r1=282621&r2=282622&view=diff
==============================================================================
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Wed Sep 28 14:44:50 2016
@@ -772,10 +772,15 @@ Clang version they became available:</p>
         Clang 3.6 (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4200">N4200</a>)</a>
       </td>
     </tr>
+    <tr>
+      <td class="svn" align="center">
+        SVN (<a href="http://wg21.link/p0096r2">P0096R2</a>)</a>
+      </td>
+    </tr>
     <!-- FIXME: Implement latest recommendations.
     <tr>
       <td class="svn" align="center">
-        SVN (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0096r0">P0096R0</a>)</a>
+        SVN (<a href="http://wg21.link/p0096r3">P0096R3</a>)</a>
       </td>
     </tr>
     -->




More information about the cfe-commits mailing list