Skip to content

Commit

Permalink
Fix #12353 FP duplInheritedMember on deleted method
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 15, 2024
1 parent 5ef846a commit cd1e0ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,8 @@ static std::vector<DuplMemberFuncInfo> getDuplInheritedMemberFunctionsRecursive(
(parentClassFuncIt.access != AccessControl::Private || !skipPrivate) &&
!classFuncIt.isConstructor() && !classFuncIt.isDestructor() &&
classFuncIt.argsMatch(parentClassIt.type->classScope, parentClassFuncIt.argDef, classFuncIt.argDef, emptyString, 0) &&
(classFuncIt.isConst() == parentClassFuncIt.isConst() || Function::returnsConst(&classFuncIt) == Function::returnsConst(&parentClassFuncIt)))
(classFuncIt.isConst() == parentClassFuncIt.isConst() || Function::returnsConst(&classFuncIt) == Function::returnsConst(&parentClassFuncIt)) &&
!(classFuncIt.isDelete() || parentClassFuncIt.isDelete()))
results.emplace_back(&classFuncIt, &parentClassFuncIt, &parentClassIt);
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,17 @@ class TestClass : public TestFixture {
" const int& get() const { return i; }\n"
"};\n");
ASSERT_EQUALS("", errout.str());

checkDuplInheritedMembers("class Base {\n" // #12353
" public:\n"
" void One();\n"
" void Two();\n"
"};\n"
"class Derived : public Base {\n"
"public:\n"
" void Two() = delete;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}

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

0 comments on commit cd1e0ea

Please sign in to comment.