Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ void CheckUnusedVarImpl::checkFunctionVariableUsage_iterateScopes(const Scope* c
const Token * const equal = skipBracketsAndMembers(tok->next());

// checked for chained assignments
if (tok != start && equal && equal->str() == "=") {
if (tok != start && (Token::simpleMatch(equal, "=") || (start->astParent() && Token::simpleMatch(start->astParent()->astParent(), "=")))) {
const nonneg int varId = tok->varId();
const Variables::VariableUsage * const var = variables.find(varId);

Expand Down
8 changes: 8 additions & 0 deletions test/testunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3370,6 +3370,14 @@ class TestUnusedVar : public TestFixture {
" return a;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5:14]: (style) Variable 'b[c]' is assigned a value that is never used. [unreadVariable]\n", errout_str());

functionVariableUsage("int f() {\n" // #14769
" int i = 2;\n"
" const int *a, *c;\n"
" a = c = &i;\n"
" return *a;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4:11]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", errout_str());
}

void localvar24() { // ticket #1803
Expand Down
Loading