[clang] d1bcac0 - [Clang] Bump `__cpp_constexpr` to `202002L` in C++20 mode (#129814)

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 02:25:09 PST 2025


Author: A. Jiang
Date: 2025-03-05T18:25:06+08:00
New Revision: d1bcac06c7c11699e7931bb7315a1bb9b9784179

URL: https://github.com/llvm/llvm-project/commit/d1bcac06c7c11699e7931bb7315a1bb9b9784179
DIFF: https://github.com/llvm/llvm-project/commit/d1bcac06c7c11699e7931bb7315a1bb9b9784179.diff

LOG: [Clang] Bump `__cpp_constexpr` to `202002L` in C++20 mode (#129814)

Per P2493R0 and SD6, `__cpp_constexpr` of value `202002L` indicates that
P1330R0 "Changing the active member of a union inside constexpr" is
implemented, which is true for Clang 9 and later.

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/Frontend/InitPreprocessor.cpp
    clang/test/Lexer/cxx-features.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 38111db3e6919..35efa2ca4aa93 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -96,6 +96,9 @@ Resolutions to C++ Defect Reports
 - Implemented `CWG2918 Consideration of constraints for address of overloaded `
   `function <https://cplusplus.github.io/CWG/issues/2918.html>`_
 
+- Bumped the ``__cpp_constexpr`` feature-test macro to ``202002L`` in C++20 mode as indicated in
+  `P2493R0 <https://wg21.link/P2493R0>`_.
+
 C Language Changes
 ------------------
 

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index e1dc728558def..1a816cb6269d4 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -664,7 +664,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
     Builder.defineMacro("__cpp_lambdas", "200907L");
     Builder.defineMacro("__cpp_constexpr", LangOpts.CPlusPlus26   ? "202406L"
                                            : LangOpts.CPlusPlus23 ? "202211L"
-                                           : LangOpts.CPlusPlus20 ? "201907L"
+                                           : LangOpts.CPlusPlus20 ? "202002L"
                                            : LangOpts.CPlusPlus17 ? "201603L"
                                            : LangOpts.CPlusPlus14 ? "201304L"
                                                                   : "200704");

diff  --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp
index ff9a1a1210c44..8c1867d5c7365 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -314,7 +314,7 @@
 #error "wrong value for __cpp_lambdas"
 #endif
 
-#if check(constexpr, 0, 200704, 201304, 201603, 201907, 202211, 202406L)
+#if check(constexpr, 0, 200704, 201304, 201603, 202002, 202211, 202406L)
 #error "wrong value for __cpp_constexpr"
 #endif
 


        


More information about the cfe-commits mailing list