Skip to content

Commit 593cf5f

Browse files
Fix #12390 FP selfAssignment for unknown struct member (#5924)
1 parent d6bca49 commit 593cf5f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,7 @@ static const Token* findExpressionChangedImpl(const Token* expr,
29552955
global = true;
29562956
}
29572957

2958-
if (tok->exprId() > 0) {
2958+
if (tok->exprId() > 0 || global) {
29592959
const Token* modifedTok = find(start, end, [&](const Token* tok2) {
29602960
int indirect = 0;
29612961
if (const ValueType* vt = tok->valueType()) {

test/testother.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5619,6 +5619,14 @@ class TestOther : public TestFixture {
56195619
" i = b[idx];\n"
56205620
"};\n");
56215621
ASSERT_EQUALS("", errout.str());
5622+
5623+
check("void g(int*);\n" // #12390
5624+
"void f() {\n"
5625+
" int o = s.i;\n"
5626+
" g(&s.i);\n"
5627+
" s.i = o;\n"
5628+
"}\n");
5629+
ASSERT_EQUALS("", errout.str());
56225630
}
56235631

56245632
void trac1132() {

0 commit comments

Comments
 (0)