[clang] [C++20] [Modules] Set the feature testing macro to 1 (PR #161034)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 27 20:09:03 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Chuanqi Xu (ChuanqiXu9)
<details>
<summary>Changes</summary>
See https://github.com/llvm/llvm-project/issues/71364 for details.
---
Full diff: https://github.com/llvm/llvm-project/pull/161034.diff
2 Files Affected:
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (+4-1)
- (modified) clang/test/Lexer/cxx-features.cpp (+1-1)
``````````diff
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index edf0a091e087c..877ab02850667 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -742,7 +742,10 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
Builder.defineMacro("__cpp_impl_coroutine", "201902L");
Builder.defineMacro("__cpp_designated_initializers", "201707L");
Builder.defineMacro("__cpp_impl_three_way_comparison", "201907L");
- //Builder.defineMacro("__cpp_modules", "201907L");
+ // Intentionally to set __cpp_modules to 1.
+ // See https://github.com/llvm/llvm-project/issues/71364 for details.
+ // Builder.defineMacro("__cpp_modules", "201907L");
+ Builder.defineMacro("__cpp_modules", "1");
Builder.defineMacro("__cpp_using_enum", "201907L");
}
// C++23 features.
diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp
index ced5bcaf0db16..8eb9ea032879c 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -148,7 +148,7 @@
// init_captures checked below
-#if check(modules, 0, 0, 0, 0, 0, 0, 0)
+#if check(modules, 0, 0, 0, 0, 1, 1, 1)
// FIXME: 201907 in C++20
#error "wrong value for __cpp_modules"
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/161034
More information about the cfe-commits
mailing list