Fixed #5381 (Some false positives that came up when using --enable=performance file.c)

This commit is contained in:
Daniel Marjamäki 2014-02-23 11:02:39 +01:00
parent 43d48574c5
commit 8dd7f02e45
2 changed files with 12 additions and 1 deletions

View File

@ -669,7 +669,7 @@ void CheckOther::checkRedundantAssignment()
} else if (Token::Match(tok, "break|return|continue|throw|goto")) {
varAssignments.clear();
memAssignments.clear();
} else if (tok->type() == Token::eVariable) {
} else if (tok->type() == Token::eVariable && !Token::Match(tok,"%var% (")) {
// Set initialization flag
if (!Token::Match(tok, "%var% ["))
initialized.insert(tok->varId());

View File

@ -6374,6 +6374,17 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
check("struct AB { int a; int b; };\n"
"\n"
"int f(DO_SOMETHING do_something) {\n"
" struct AB ab;\n"
" ab.a = 1;\n"
" do_something(&ab);\n"
" ab.a = 2;\n"
" return ab.a;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("struct AB { int a; int b; };\n"
"\n"
"int f(struct AB *ab) {\n"