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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 29 10:10:09 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();
----------------
AaronBallman wrote:

I was thinking this was similar to reserved identifiers, but I think your suggestion is cleaner. I'll work on an update for that

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


More information about the cfe-commits mailing list