Skip to content
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
4 changes: 2 additions & 2 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ bool exprDependsOnThis(const Token* expr, bool onVar, nonneg int depth)
return false;
} else if (onVar && expr->variable()) {
const Variable* var = expr->variable();
return (var->isPrivate() || var->isPublic() || var->isProtected());
return ((var->isPrivate() || var->isPublic() || var->isProtected()) && !var->isStatic());
}
if (Token::simpleMatch(expr, "."))
return exprDependsOnThis(expr->astOperand1(), onVar, depth);
Expand Down Expand Up @@ -2581,7 +2581,7 @@ bool isThisChanged(const Token* tok, int indirect, const Settings* settings, boo
if ((Token::Match(tok->previous(), "%name% (") && !Token::simpleMatch(tok->astOperand1(), ".")) ||
Token::Match(tok->tokAt(-3), "this . %name% (")) {
if (tok->previous()->function()) {
return (!tok->previous()->function()->isConst());
return (!tok->previous()->function()->isConst() && !tok->previous()->function()->isStatic());
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not instrumental to this fix, but seemed incorrect.

} else if (!tok->previous()->isKeyword()) {
return true;
}
Expand Down
11 changes: 11 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4239,6 +4239,17 @@ class TestCondition : public TestFixture {
" return col;\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("struct S {\n" // #11233
" static std::string m;\n"
" static void f() { m = \"abc\"; }\n"
" static void g() {\n"
" m.clear();\n"
" f();\n"
" if (m.empty()) {}\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}

void alwaysTrueSymbolic()
Expand Down