From 775cf85092ebfe333308bc51ab729ae19c3da798 Mon Sep 17 00:00:00 2001 From: chrchr Date: Thu, 15 Feb 2024 16:57:47 +0100 Subject: [PATCH] Fix #12374 FP duplInheritedMember with template in namespace --- lib/checkclass.cpp | 2 ++ test/testclass.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) 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__)