Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12390 FP selfAssignment for unknown struct member #5924

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading