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

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 02:54:33 PST 2026


================
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++-keyword %s
+// RUN: %clang_cc1 -x c++ -std=c++98 -fsyntax-only -verify -Wc++11-compat %s
+
+#define ID(x) x
+#define DISCARD(x)
+#define EXPAND_AND_DISCARD(x) DISCARD(x)
+
+#ifndef __cplusplus
----------------
zwuis wrote:

Another option is removing the condition and verifying different diagnostic messages in different language versions, but I'm fine with either.

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


More information about the cfe-commits mailing list