[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
================
@@ -258,8 +283,13 @@ static void AddKeyword(StringRef Keyword,
const LangOptions &LangOpts, IdentifierTable &Table) {
KeywordStatus AddResult = getKeywordStatus(LangOpts, Flags);
- // Don't add this keyword if disabled in this language.
- if (AddResult == KS_Disabled) return;
+ // Don't add this keyword if disabled in this language and isn't otherwise
+ // special.
+ if (AddResult == KS_Disabled) {
----------------
zygoloid wrote:
Optional:
It'd be more consistent with the existing code to add an extra KeywordStatus value for this case, analogous to KS_Future. To do that, maybe we'd need to also replace the special macro for C++ operator keywords with a normal flag so that it can be taken into account when computing the KeywordStatus too.
I don't think it's necessary to be consistent here, though; we can always refactor later.
https://github.com/llvm/llvm-project/pull/137234
More information about the cfe-commits
mailing list