Missing override specifier warning on a pure virtual function makes no sense. (#1230)

This fixes a large number of false positives for cppcheck source code.
This commit is contained in:
IOBYTE 2018-05-14 17:08:40 -04:00 committed by Daniel Marjamäki
parent d8622ea5f8
commit 348eb1c5c9
2 changed files with 15 additions and 1 deletions

View File

@ -2584,7 +2584,7 @@ void CheckClass::checkOverride()
if (func.hasOverrideSpecifier() || func.hasFinalSpecifier()) if (func.hasOverrideSpecifier() || func.hasFinalSpecifier())
continue; continue;
const Function *baseFunc = func.getOverridenFunction(); const Function *baseFunc = func.getOverridenFunction();
if (baseFunc) if (baseFunc && !baseFunc->isPure())
overrideError(baseFunc, &func); overrideError(baseFunc, &func);
} }
} }

View File

@ -212,6 +212,7 @@ private:
TEST_CASE(unsafeClassDivZero); TEST_CASE(unsafeClassDivZero);
TEST_CASE(override1); TEST_CASE(override1);
TEST_CASE(override2);
} }
void checkCopyCtorAndEqOperator(const char code[]) { void checkCopyCtorAndEqOperator(const char code[]) {
@ -6782,6 +6783,19 @@ private:
"class Derived : Base { virtual void f() final; };"); "class Derived : Base { virtual void f() final; };");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void override2() {
checkOverride("class TimerResultsIntf {\n"
"public:\n"
" virtual void AddResults(const std::string& str, std::clock_t clocks) = 0;\n"
"};\n"
"class TimerResults : public TimerResultsIntf {\n"
"public:\n"
" virtual void AddResults(const std::string& str, std::clock_t clocks);\n"
"};");
ASSERT_EQUALS("", errout.str());
};
}; };
REGISTER_TEST(TestClass) REGISTER_TEST(TestClass)