Skip to content

Commit

Permalink
Fix #12374 FP duplInheritedMember with template in namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Feb 15, 2024
1 parent d145f9c commit 775cf85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3013,6 +3013,8 @@ static std::vector<DuplMemberFuncInfo> 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) &&
Expand Down
13 changes: 13 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,19 @@ class TestClass : public TestFixture {
" void Two() = delete;\n"
"};\n");
ASSERT_EQUALS("", errout.str());

checkDuplInheritedMembers("namespace N {\n" // #12374
" template<typename T>\n"
" struct B {\n"
" std::unique_ptr<B<T>> clone() const = 0;\n"
" };\n"
" struct D : public B<int> {\n"
" std::unique_ptr<B<int>> clone() const final {\n"
" return std::make_unique<D>(*this);\n"
" }\n"
" };\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

#define checkCopyConstructor(code) checkCopyConstructor_(code, __FILE__, __LINE__)
Expand Down

0 comments on commit 775cf85

Please sign in to comment.