[clang] b3fe1b6 - [C++20] [Modules] Set the feature testing macro to 1 (#161034)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 29 00:01:09 PDT 2025


Author: Chuanqi Xu
Date: 2025-09-29T15:01:05+08:00
New Revision: b3fe1b6db39e42e73131b483f4401f4bf3b05444

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

LOG: [C++20] [Modules] Set the feature testing macro to 1 (#161034)

See https://github.com/llvm/llvm-project/issues/71364 for details.

Added: 
    

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

Removed: 
    


################################################################################
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


        


More information about the cfe-commits mailing list