This commit is contained in:
parent
96955ccfe9
commit
b99931c59c
|
@ -4388,13 +4388,13 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
|
||||||
auto range = parent->functionMap.equal_range(tokenDef->str());
|
auto range = parent->functionMap.equal_range(tokenDef->str());
|
||||||
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
|
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
|
||||||
const Function * func = it->second;
|
const Function * func = it->second;
|
||||||
if (func->hasVirtualSpecifier()) { // Base is virtual and of same name
|
if (func->isImplicitlyVirtual()) { // Base is virtual and of same name
|
||||||
const Token *temp1 = func->tokenDef->previous();
|
const Token *temp1 = func->tokenDef->previous();
|
||||||
const Token *temp2 = tokenDef->previous();
|
const Token *temp2 = tokenDef->previous();
|
||||||
bool match = true;
|
bool match = true;
|
||||||
|
|
||||||
// check for matching return parameters
|
// check for matching return parameters
|
||||||
while (temp1->str() != "virtual") {
|
while (!Token::Match(temp1, "virtual|{|}|;")) {
|
||||||
if (temp1->str() != temp2->str() &&
|
if (temp1->str() != temp2->str() &&
|
||||||
!(temp1->str() == derivedFromType->name() &&
|
!(temp1->str() == derivedFromType->name() &&
|
||||||
temp2->str() == baseType->name())) {
|
temp2->str() == baseType->name())) {
|
||||||
|
|
|
@ -8440,6 +8440,15 @@ private:
|
||||||
" void g() { f(); }\n"
|
" void g() { f(); }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUselessOverride("struct B { virtual void f(); };\n" // #11808
|
||||||
|
"struct D : B { void f() override {} };\n"
|
||||||
|
"struct D2 : D {\n"
|
||||||
|
" void f() override {\n"
|
||||||
|
" B::f();\n"
|
||||||
|
" }\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#define checkUnsafeClassRefMember(code) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)
|
#define checkUnsafeClassRefMember(code) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)
|
||||||
|
|
Loading…
Reference in New Issue