================
@@ -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;
+
----------------
yronglin wrote:
I try to implementing a more precise control of warn on special meaning
identifiers. IMO, we can warning iff the macro real impact a keyword:
```cpp
class A final {};
#define final var // It's ok, right?
int bar() {
int final = 0;
return final++;
}
```
https://github.com/llvm/llvm-project/pull/218322
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits