Skip to content

Commit

Permalink
Fix #12390 FP selfAssignment for unknown struct member (#5924)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 31, 2024
1 parent d6bca49 commit 593cf5f
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 @@ -2955,7 +2955,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 593cf5f

Please sign in to comment.