Skip to content

Commit

Permalink
Fix #12390 FP selfAssignment for unknown struct member
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 30, 2024
1 parent ab93362 commit a779606
Show file tree
Hide file tree
Showing 2 changed files with 9 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 @@ -2947,7 +2947,7 @@ static const Token* findExpressionChangedImpl(const Token* expr,
global = true;
}

if (tok->exprId() > 0) {
if (tok->exprId() > 0 || global) {
const Token* modifedTok = find(start, end, [&](const Token* tok2) {
int indirect = 0;
if (const ValueType* vt = tok->valueType()) {
Expand Down
8 changes: 8 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5619,6 +5619,14 @@ class TestOther : public TestFixture {
" i = b[idx];\n"
"};\n");
ASSERT_EQUALS("", errout.str());

check("void g(int*);\n" // #12390
"void f() {\n"
" int o = s.i;\n"
" g(&s.i);\n"
" s.i = o;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void trac1132() {
Expand Down

0 comments on commit a779606

Please sign in to comment.