[clang] [clang][Lex] Diagnose keywords in macro expansions (PR #242626)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 00:22:51 PST 2026


================
@@ -16,3 +31,31 @@ TY(1) x; // FIXME: And we should warn here
 // inline, restrict, asm, typeof, _asm
 
 void whatever(void) {}
+
+#define CLASS class
+void macro_keyword(void) {
+  int CLASS; // expected-warning {{identifier 'class' conflicts with a C++ keyword}}
+}
+
+void macro_argument_keyword(void) {
+  int ID(CLASS); // expected-warning {{identifier 'class' conflicts with a C++ keyword}}
----------------
zwuis wrote:

Do we have tests with things like `ID(constexpr)`?

https://github.com/llvm/llvm-project/pull/242626


More information about the cfe-commits mailing list