diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 4ba5c964951..2a8c5b88496 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3013,6 +3013,8 @@ static std::vector getDuplInheritedMemberFunctionsRecursive( for (const Function& classFuncIt : typeCurrent->classScope->functionList) { if (classFuncIt.isImplicitlyVirtual()) continue; + if (classFuncIt.hasFinalSpecifier()) + continue; for (const Function& parentClassFuncIt : parentClassIt.type->classScope->functionList) { if (classFuncIt.name() == parentClassFuncIt.name() && (parentClassFuncIt.access != AccessControl::Private || !skipPrivate) && diff --git a/test/testclass.cpp b/test/testclass.cpp index 8d6fb0478cb..1946d705953 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -726,6 +726,19 @@ class TestClass : public TestFixture { " void Two() = delete;\n" "};\n"); ASSERT_EQUALS("", errout.str()); + + checkDuplInheritedMembers("namespace N {\n" // #12374 + " template\n" + " struct B {\n" + " std::unique_ptr> clone() const = 0;\n" + " };\n" + " struct D : public B {\n" + " std::unique_ptr> clone() const final {\n" + " return std::make_unique(*this);\n" + " }\n" + " };\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } #define checkCopyConstructor(code) checkCopyConstructor_(code, __FILE__, __LINE__)