Fixx issue 9355: FP constParameter when returning non-const reference to struct member (#2373)
This commit is contained in:
parent
7f6ebaa6b2
commit
ed1acc319d
|
@ -1357,7 +1357,7 @@ void CheckOther::checkConstVariable()
|
|||
if (isVariableChanged(var, mSettings, mTokenizer->isCPP()))
|
||||
continue;
|
||||
if (Function::returnsReference(function) &&
|
||||
Token::findmatch(var->nameToken(), "return %varid% ;|[", scope->bodyEnd, var->declarationId()))
|
||||
Token::findmatch(var->nameToken(), "return %varid% ;|[|.", scope->bodyEnd, var->declarationId()))
|
||||
continue;
|
||||
// Skip if address is taken
|
||||
if (Token::findmatch(var->nameToken(), "& %varid%", scope->bodyEnd, var->declarationId()))
|
||||
|
|
|
@ -1946,6 +1946,14 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct S {\n"
|
||||
" int i;\n"
|
||||
"};\n"
|
||||
"int& f(S& s) {\n"
|
||||
" return s.i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void e();\n"
|
||||
"void g(void);\n"
|
||||
"void h(void);\n"
|
||||
|
|
Loading…
Reference in New Issue