#11233 FP: knownConditionTrueFalse (wrong message text) (#4330)

* #11233 FP: knownConditionTrueFalse (wrong message text)

* Format

* Update testcondition.cpp

* Trigger CI
This commit is contained in:
chrchr-github 2022-08-02 18:18:46 +02:00 committed by GitHub
parent b13e42978c
commit 92d569afb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -945,7 +945,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);
@ -2578,7 +2578,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());
} else if (!tok->previous()->isKeyword()) {
return true;
}

View File

@ -4249,6 +4249,17 @@ private:
" 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()