Skip to content
Merged
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
3 changes: 1 addition & 2 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3704,8 +3704,7 @@ static bool isVariableExpression(const Token* tok)
return isVariableExpression(tok->astOperand1()) &&
isVariableExpression(tok->astOperand2());
if (Token::simpleMatch(tok, "["))
return isVariableExpression(tok->astOperand1()) &&
tok->astOperand2() && tok->astOperand2()->hasKnownIntValue();
return isVariableExpression(tok->astOperand1());
return false;
}

Expand Down
14 changes: 14 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11041,6 +11041,20 @@ class TestOther : public TestFixture {
" if (g(k(i))) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());

// #11889
check("struct S {\n"
" int a[5];\n"
" void f(int i);\n"
"}\n"
"void g(int);\n"
"void S::f(int i) {\n"
" if (a[i] == 1) {\n"
" a[i] = 0;\n"
" g(a[i]);\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void knownArgumentHiddenVariableExpression() {
Expand Down