File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3087,6 +3087,12 @@ void CheckClass::checkUselessOverride()
30873087 const Function* baseFunc = func.getOverriddenFunction ();
30883088 if (!baseFunc || baseFunc->isPure () || baseFunc->access != func.access )
30893089 continue ;
3090+ if (std::any_of (classScope->functionList .begin (), classScope->functionList .end (), [&func](const Function& f) { // check for overloads
3091+ if (&f == &func)
3092+ return false ;
3093+ return f.name () == func.name ();
3094+ }))
3095+ continue ;
30903096 if (const Token* const call = getSingleFunctionCall (func.functionScope )) {
30913097 if (call->function () != baseFunc)
30923098 continue ;
Original file line number Diff line number Diff line change @@ -8429,6 +8429,17 @@ class TestClass : public TestFixture {
84298429 " B::f(a, b, m);\n "
84308430 " };" );
84318431 ASSERT_EQUALS (" " , errout.str ());
8432+
8433+ checkUselessOverride (" struct B {\n " // #11803
8434+ " virtual void f();\n "
8435+ " virtual void f(int i);\n "
8436+ " };\n "
8437+ " struct D : B {\n "
8438+ " void f() override { B::f(); }\n "
8439+ " void f(int i) override;\n "
8440+ " void g() { f(); }\n "
8441+ " };" );
8442+ ASSERT_EQUALS (" " , errout.str ());
84328443 }
84338444
84348445#define checkUnsafeClassRefMember (code ) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)
You can’t perform that action at this time.
0 commit comments