Skip to content

Commit

Permalink
Fix #13226 FP constParameterReference with array member (regression) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Oct 16, 2024
1 parent 4da801e commit be6ec8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2601,7 +2601,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings &settings,
const Token *tok2 = tok;
int derefs = 0;
while ((tok2->astParent() && tok2->astParent()->isUnaryOp("*")) ||
(Token::simpleMatch(tok2->astParent(), ".") && !Token::simpleMatch(tok2->astParent()->astParent(), "(")) ||
(Token::simpleMatch(tok2->astParent(), ".") && !Token::Match(tok2->astParent()->astParent(), "[(,]")) ||
(tok2->astParent() && tok2->astParent()->isUnaryOp("&") && Token::simpleMatch(tok2->astParent()->astParent(), ".") && tok2->astParent()->astParent()->originalName()=="->") ||
(Token::simpleMatch(tok2->astParent(), "[") && tok2 == tok2->astParent()->astOperand1())) {
if (tok2->astParent() && (tok2->astParent()->isUnaryOp("*") || (astIsLHS(tok2) && tok2->astParent()->originalName() == "->")))
Expand Down
7 changes: 7 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3743,6 +3743,13 @@ class TestOther : public TestFixture {
" return lam();\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("struct S { int x[3]; };\n" // #13226
"void g(int a, int* b);\n"
"void f(int a, S& s) {\n"
" return g(a, s.x);\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void constParameterCallback() {
Expand Down

0 comments on commit be6ec8f

Please sign in to comment.