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

Chen Miao via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 01:17:40 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}}
----------------
ChenMiaoi wrote:

Done, but in another file

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


More information about the cfe-commits mailing list