Fix FP in CheckUnusedVar. Caused by #7230 fix.

This commit is contained in:
Daniel Marjamäki 2015-12-31 15:30:33 +01:00
parent 7c1a4da6a4
commit 350908d0e9
2 changed files with 10 additions and 1 deletions

View File

@ -897,8 +897,10 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
if (tok && tok->isAssignmentOp() && tok->str() != "=") { if (tok && tok->isAssignmentOp() && tok->str() != "=") {
variables.use(varid1, tok); variables.use(varid1, tok);
if (Token::Match(tok, "%assign% %name%")) if (Token::Match(tok, "%assign% %name%")) {
tok = tok->next(); tok = tok->next();
variables.read(tok->varId(), tok);
}
} }
if (pre || post) if (pre || post)

View File

@ -3153,6 +3153,13 @@ private:
" return a;\n" " return a;\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
functionVariableUsage("void f() {\n"
" Fred fred;\n"
" int *a; a = b;\n"
" fred += a;\n"
"}");
ASSERT_EQUALS("", errout.str());
} }
void localvarFor() { void localvarFor() {