Fix issue 8884: Regression: False positive: Variable 'f' is reassigned a value before the old one has been used (#1513)

This commit is contained in:
Paul Fultz II 2018-12-08 00:33:51 -06:00 committed by Daniel Marjamäki
parent 0ab378b9cf
commit 6953dddfa6
2 changed files with 11 additions and 0 deletions

View File

@ -490,6 +490,9 @@ void CheckOther::checkRedundantAssignment()
if (!nextAssign)
continue;
if (nextAssign == tok)
continue;
// there is redundant assignment. Is there a case between the assignments?
bool hasCase = false;

View File

@ -5968,6 +5968,14 @@ private:
" memptr = 0;\n"
"}");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Variable 'memptr' is reassigned a value before the old one has been used.\n", errout.str());
// issue #8884
check("template <class F, class... Ts>\n"
"auto foo(F f, Ts... xs) {\n"
" auto x = f(xs...);\n"
" return x;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void redundantVarAssignment_struct() {