File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4388,13 +4388,13 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
43884388 auto range = parent->functionMap .equal_range (tokenDef->str ());
43894389 for (std::multimap<std::string, const Function*>::const_iterator it = range.first ; it != range.second ; ++it) {
43904390 const Function * func = it->second ;
4391- if (func->hasVirtualSpecifier ()) { // Base is virtual and of same name
4391+ if (func->isImplicitlyVirtual ()) { // Base is virtual and of same name
43924392 const Token *temp1 = func->tokenDef ->previous ();
43934393 const Token *temp2 = tokenDef->previous ();
43944394 bool match = true ;
43954395
43964396 // check for matching return parameters
4397- while (temp1-> str () != " virtual" ) {
4397+ while (! Token::Match (temp1, " virtual|{|}|; " ) ) {
43984398 if (temp1->str () != temp2->str () &&
43994399 !(temp1->str () == derivedFromType->name () &&
44004400 temp2->str () == baseType->name ())) {
Original file line number Diff line number Diff line change @@ -8440,6 +8440,15 @@ class TestClass : public TestFixture {
84408440 " void g() { f(); }\n "
84418441 " };" );
84428442 ASSERT_EQUALS (" " , errout.str ());
8443+
8444+ checkUselessOverride (" struct B { virtual void f(); };\n " // #11808
8445+ " struct D : B { void f() override {} };\n "
8446+ " struct D2 : D {\n "
8447+ " void f() override {\n "
8448+ " B::f();\n "
8449+ " }\n "
8450+ " };" );
8451+ ASSERT_EQUALS (" " , errout.str ());
84438452 }
84448453
84458454#define checkUnsafeClassRefMember (code ) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)
You can’t perform that action at this time.
0 commit comments