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:
parent
d8622ea5f8
commit
348eb1c5c9
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue