diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index c5981cb53..abf831924 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -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; diff --git a/test/testclass.cpp b/test/testclass.cpp index add011fe4..53371d545 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -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__)