================
@@ -213,7 +215,16 @@ static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, 
IdentifierInfo *II) {
 
 static MacroDiag shouldWarnOnMacroUndef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  // Do not warn on keyword undef.  It is generally harmless and widely used.
+  StringRef Text = II->getName();
+  if (II->isKeyword(Lang))
+    return MD_KeywordUndef;
+
+  // [lex.name]/p2: Identifiers with special meaning
+  if ((Lang.CPlusPlus26 && (Text == "post" || Text == "pre")) ||
+      (Lang.CPlusPlus20 && (Text == "module" || Text == "import")) ||
+      (Lang.CPlusPlus11 && (Text == "override" || Text == "final")))
+    return MD_KeywordUndef;
+
----------------
cor3ntin wrote:

I do actually wonder if we shouldn't warn on these unconditionally.
Although we could use a different warning depending on whether the keyword is 
useful in a given language modes.

In particular
 - I don't see any reason why we would not allow contracts in oldfer language 
modes
 - We do accept final / override in C++98 mode today

@hubert-reinterpretcast @AaronBallman 

https://github.com/llvm/llvm-project/pull/218322
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to