[clang] [C11] Diagnose C11 keywords as being incompatible w/earlier standards (PR #82015)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 16 10:06:41 PST 2024
================
@@ -2742,6 +2742,19 @@ bool Parser::parseMisplacedModuleImport() {
return false;
}
+void Parser::diagnoseUseOfC11Keyword(const Token& Tok) {
+ // Warn that this is a C11 extension if in an older mode or if in C++.
+ // Otherwise, warn that it is incompatible with standards before C11 if in
+ // C11 or later.
+ unsigned DiagId;
+ if (!getLangOpts().C11) {
+ DiagId = diag::ext_c11_feature;
+ } else {
+ DiagId = diag::warn_c11_compat_keyword;
+ }
+ Diag(Tok, DiagId) << Tok.getName();
----------------
AaronBallman wrote:
Yeah, I had originally structured it this way because I thought we might want to give a different diagnostic in C++ mode (where we call these C11 extensions), but then I realized that diagnostic is reasonable as-is. I'll change.
https://github.com/llvm/llvm-project/pull/82015
More information about the cfe-commits
mailing list