Skip to content

Commit

Permalink
Fix FP uselessOverride with macro
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 13, 2023
1 parent c0bd9f8 commit 4f1dee7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8565,6 +8565,13 @@ class TestClass : public TestFixture {
" 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__)
Expand Down

0 comments on commit 4f1dee7

Please sign in to comment.