Fixed #5381 (Some false positives that came up when using --enable=performance file.c)
This commit is contained in:
parent
43d48574c5
commit
8dd7f02e45
|
@ -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());
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue