Fix FP uselessOverride with macro (#5238)

This commit is contained in:
chrchr-github 2023-07-13 12:18:29 +02:00 committed by GitHub
parent c0bd9f8bbd
commit 258581ce2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -3151,6 +3151,8 @@ static bool compareTokenRanges(const Token* start1, const Token* end1, const Tok
break;
if (tok1->str() == "this")
break;
if (tok1->isExpandedMacro() || tok2->isExpandedMacro())
break;
if (tok1 == end1 && tok2 == end2) {
isEqual = true;
break;

View File

@ -8565,6 +8565,13 @@ private:
" int f() const override { return g(); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
checkUselessOverride("#define MACRO 1\n"
"struct B { virtual int f() { return 1; } };\n"
"struct D : B {\n"
" int f() override { return MACRO; }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
#define checkUnsafeClassRefMember(code) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)