This commit is contained in:
parent
e9feeef81d
commit
6d9fa6f10a
|
@ -3087,6 +3087,12 @@ void CheckClass::checkUselessOverride()
|
||||||
const Function* baseFunc = func.getOverriddenFunction();
|
const Function* baseFunc = func.getOverriddenFunction();
|
||||||
if (!baseFunc || baseFunc->isPure() || baseFunc->access != func.access)
|
if (!baseFunc || baseFunc->isPure() || baseFunc->access != func.access)
|
||||||
continue;
|
continue;
|
||||||
|
if (std::any_of(classScope->functionList.begin(), classScope->functionList.end(), [&func](const Function& f) { // check for overloads
|
||||||
|
if (&f == &func)
|
||||||
|
return false;
|
||||||
|
return f.name() == func.name();
|
||||||
|
}))
|
||||||
|
continue;
|
||||||
if (const Token* const call = getSingleFunctionCall(func.functionScope)) {
|
if (const Token* const call = getSingleFunctionCall(func.functionScope)) {
|
||||||
if (call->function() != baseFunc)
|
if (call->function() != baseFunc)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -8429,6 +8429,17 @@ private:
|
||||||
" B::f(a, b, m);\n"
|
" B::f(a, b, m);\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUselessOverride("struct B {\n" // #11803
|
||||||
|
" virtual void f();\n"
|
||||||
|
" virtual void f(int i);\n"
|
||||||
|
"};\n"
|
||||||
|
"struct D : B {\n"
|
||||||
|
" void f() override { B::f(); }\n"
|
||||||
|
" void f(int i) override;\n"
|
||||||
|
" void g() { f(); }\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#define checkUnsafeClassRefMember(code) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)
|
#define checkUnsafeClassRefMember(code) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)
|
||||||
|
|
Loading…
Reference in New Issue