Skip to content

Commit be6ec8f

Browse files
Fix #13226 FP constParameterReference with array member (regression) (danmar#6921)
1 parent 4da801e commit be6ec8f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2601,7 +2601,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings &settings,
26012601
const Token *tok2 = tok;
26022602
int derefs = 0;
26032603
while ((tok2->astParent() && tok2->astParent()->isUnaryOp("*")) ||
2604-
(Token::simpleMatch(tok2->astParent(), ".") && !Token::simpleMatch(tok2->astParent()->astParent(), "(")) ||
2604+
(Token::simpleMatch(tok2->astParent(), ".") && !Token::Match(tok2->astParent()->astParent(), "[(,]")) ||
26052605
(tok2->astParent() && tok2->astParent()->isUnaryOp("&") && Token::simpleMatch(tok2->astParent()->astParent(), ".") && tok2->astParent()->astParent()->originalName()=="->") ||
26062606
(Token::simpleMatch(tok2->astParent(), "[") && tok2 == tok2->astParent()->astOperand1())) {
26072607
if (tok2->astParent() && (tok2->astParent()->isUnaryOp("*") || (astIsLHS(tok2) && tok2->astParent()->originalName() == "->")))

test/testother.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,6 +3743,13 @@ class TestOther : public TestFixture {
37433743
" return lam();\n"
37443744
"}\n");
37453745
ASSERT_EQUALS("", errout_str());
3746+
3747+
check("struct S { int x[3]; };\n" // #13226
3748+
"void g(int a, int* b);\n"
3749+
"void f(int a, S& s) {\n"
3750+
" return g(a, s.x);\n"
3751+
"}\n");
3752+
ASSERT_EQUALS("", errout_str());
37463753
}
37473754

37483755
void constParameterCallback() {

0 commit comments

Comments
 (0)