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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri May 2 06:40:26 PDT 2025


================
@@ -250,6 +250,32 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts,
   return CurStatus;
 }
 
+static bool IsKeywordInCpp(unsigned Flags) {
+  while (Flags != 0) {
+    unsigned CurFlag = Flags & ~(Flags - 1);
+    Flags = Flags & ~CurFlag;
+    switch (static_cast<TokenKey>(CurFlag)) {
+    case KEYCXX:
+    case KEYCXX11:
+    case KEYCXX20:
+    case BOOLSUPPORT:
+    case WCHARSUPPORT:
+    case CHAR8SUPPORT:
+      return true;
+    default:
+      break; // Go to the next flag, try again.
+    }
+  }
+  return false;
----------------
AaronBallman wrote:

I updated in 0b2ab11321d2b400987e9ade28a221dff67aea7d thank you for the catch!

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


More information about the cfe-commits mailing list