[clang] [C] Diagnose use of C++ keywords in C (PR #137234)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 29 09:55:24 PDT 2025


================
@@ -6118,6 +6120,10 @@ void Sema::warnOnReservedIdentifier(const NamedDecl *D) {
     Diag(D->getLocation(), diag::warn_reserved_extern_symbol)
         << D << static_cast<int>(Status);
   }
+  // Diagnose use of C++ keywords in C as being incompatible with C++.
+  if (const IdentifierInfo *II = D->getIdentifier();
----------------
zygoloid wrote:

Is there a reason to warn on this here rather than in the same place we warn on "future keywords"? (When the preprocessor produces the final identifier token.) I would worry that this check would miss some cases. (Parameter names appear to need special handling, and they're probably not going to remain the only case even if they currently are.)

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


More information about the cfe-commits mailing list