Fixed #8691 (False negative for uselessAssignmentArg)
This commit is contained in:
parent
e442bc47b1
commit
43233e72b2
|
@ -190,7 +190,7 @@ void CheckAutoVariables::assignFunctionArg()
|
||||||
// TODO: What happens if this is removed?
|
// TODO: What happens if this is removed?
|
||||||
if (tok->astParent())
|
if (tok->astParent())
|
||||||
continue;
|
continue;
|
||||||
if (!Token::Match(tok, "=|++|--") || !Token::Match(tok->astOperand1(), "%var%"))
|
if (!(tok->isAssignmentOp() || Token::Match(tok, "++|--")) || !Token::Match(tok->astOperand1(), "%var%"))
|
||||||
continue;
|
continue;
|
||||||
const Token* const vartok = tok->astOperand1();
|
const Token* const vartok = tok->astOperand1();
|
||||||
if (isNonReferenceArg(vartok) &&
|
if (isNonReferenceArg(vartok) &&
|
||||||
|
|
|
@ -274,6 +274,11 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (style) Assignment of function parameter has no effect outside the function.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (style) Assignment of function parameter has no effect outside the function.\n", errout.str());
|
||||||
|
|
||||||
|
check("void foo(int b) {\n"
|
||||||
|
" b += 1;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:2]: (style) Assignment of function parameter has no effect outside the function.\n", errout.str());
|
||||||
|
|
||||||
check("void foo(std::string s) {\n"
|
check("void foo(std::string s) {\n"
|
||||||
" s = foo(b);\n"
|
" s = foo(b);\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
Loading…
Reference in New Issue