Skip to content

Commit d1bcac0

Browse files
[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.
1 parent 7302e1b commit d1bcac0

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ Resolutions to C++ Defect Reports
9696
- Implemented `CWG2918 Consideration of constraints for address of overloaded `
9797
`function <https://cplusplus.github.io/CWG/issues/2918.html>`_
9898

99+
- Bumped the ``__cpp_constexpr`` feature-test macro to ``202002L`` in C++20 mode as indicated in
100+
`P2493R0 <https://wg21.link/P2493R0>`_.
101+
99102
C Language Changes
100103
------------------
101104

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
664664
Builder.defineMacro("__cpp_lambdas", "200907L");
665665
Builder.defineMacro("__cpp_constexpr", LangOpts.CPlusPlus26 ? "202406L"
666666
: LangOpts.CPlusPlus23 ? "202211L"
667-
: LangOpts.CPlusPlus20 ? "201907L"
667+
: LangOpts.CPlusPlus20 ? "202002L"
668668
: LangOpts.CPlusPlus17 ? "201603L"
669669
: LangOpts.CPlusPlus14 ? "201304L"
670670
: "200704");

clang/test/Lexer/cxx-features.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
#error "wrong value for __cpp_lambdas"
315315
#endif
316316

317-
#if check(constexpr, 0, 200704, 201304, 201603, 201907, 202211, 202406L)
317+
#if check(constexpr, 0, 200704, 201304, 201603, 202002, 202211, 202406L)
318318
#error "wrong value for __cpp_constexpr"
319319
#endif
320320

0 commit comments

Comments
 (0)