File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3296,6 +3296,8 @@ void CheckClass::checkUselessOverride()
32963296 if (const Token* const call = getSingleFunctionCall (func.functionScope )) {
32973297 if (call->function () != baseFunc)
32983298 continue ;
3299+ if (Token::simpleMatch (call->astParent (), " ." ))
3300+ continue ;
32993301 std::vector<const Token*> funcArgs = getArguments (func.tokenDef );
33003302 std::vector<const Token*> callArgs = getArguments (call);
33013303 if (funcArgs.size () != callArgs.size () ||
Original file line number Diff line number Diff line change @@ -8732,6 +8732,16 @@ class TestClass : public TestFixture {
87328732 " virtual void g() { std::cout << \" Derived\\ n\" ; }\n "
87338733 " };\n " );
87348734 ASSERT_EQUALS (" " , errout_str ());
8735+
8736+ checkUselessOverride (" struct B {\n " // #12946
8737+ " virtual int f() { return i; }\n "
8738+ " int i;\n "
8739+ " };\n "
8740+ " struct D : B {\n "
8741+ " int f() override { return b.f(); }\n "
8742+ " B b;\n "
8743+ " };\n " );
8744+ ASSERT_EQUALS (" " , errout_str ());
87358745 }
87368746
87378747#define checkUnsafeClassRefMember (code ) checkUnsafeClassRefMember_(code, __FILE__, __LINE__)
You can’t perform that action at this time.
0 commit comments