[clang] [C] Diagnose use of C++ keywords in C (PR #137234)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 16:18:00 PDT 2025
zygoloid wrote:
For what it's worth, the existing "keyword from language you're not using" warnings [already fire for analogous Objective-C++ cases](https://godbolt.org/z/3K6835PPK)... which in those cases is correct, since Clang does *not* accept C++11-onwards keywords as selector names in the corresponding versions of Objective-C++.
I wonder if it'd suffice to do a single-token lookahead / lookbehind in Objective-C / Objective-C++ and disable all of these warnings if the previous token is `@` or the next token is `:`. That would have false negatives for some weird cases like `class co_await : base {};` under `-Wc++20-compat` in Objective-C++17 or earlier, but that might be better than losing the warning entirely.
https://github.com/llvm/llvm-project/pull/137234
More information about the cfe-commits
mailing list