Fix 11682: False positive: constParameterReference with overloaded method (#5038)
* Fix 11682: False positive: constParameterReference with overloaded method * Format
This commit is contained in:
parent
1db510b9fd
commit
543b4adc8a
|
@ -5355,7 +5355,8 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
|
||||||
const Scope * scope = tok->scope();
|
const Scope * scope = tok->scope();
|
||||||
|
|
||||||
// check if this function is a member function
|
// check if this function is a member function
|
||||||
if (scope && scope->functionOf && scope->functionOf->isClassOrStruct() && scope->function) {
|
if (scope && scope->functionOf && scope->functionOf->isClassOrStruct() && scope->function &&
|
||||||
|
func->nestedIn == scope->functionOf) {
|
||||||
// check if isConst mismatches
|
// check if isConst mismatches
|
||||||
if (scope->function->isConst() != func->isConst()) {
|
if (scope->function->isConst() != func->isConst()) {
|
||||||
if (scope->function->isConst()) {
|
if (scope->function->isConst()) {
|
||||||
|
|
|
@ -3158,6 +3158,21 @@ private:
|
||||||
" a.fill(0);\n"
|
" a.fill(0);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'a' can be declared as const array\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'a' can be declared as const array\n", errout.str());
|
||||||
|
|
||||||
|
// #11682
|
||||||
|
check("struct b {\n"
|
||||||
|
" void mutate();\n"
|
||||||
|
"};\n"
|
||||||
|
"struct c {\n"
|
||||||
|
" const b& get() const;\n"
|
||||||
|
" b get();\n"
|
||||||
|
"};\n"
|
||||||
|
"struct d {\n"
|
||||||
|
" void f(c& e) const {\n"
|
||||||
|
" e.get().mutate();\n"
|
||||||
|
" }\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void constParameterCallback() {
|
void constParameterCallback() {
|
||||||
|
|
Loading…
Reference in New Issue