Fixed #9905 (False positive: known argument 'header.length()')
This commit is contained in:
parent
c563944fdd
commit
730b95331e
|
@ -3113,6 +3113,15 @@ void CheckOther::checkKnownArgument()
|
|||
tok2 = tok2->astOperand2();
|
||||
if (isVariableExpression(tok2))
|
||||
continue;
|
||||
// ensure that there is a integer variable in expression with unknown value
|
||||
bool intvar = false;
|
||||
visitAstNodes(tok, [&intvar](const Token *child) {
|
||||
if (child->varId() && child->valueType() && child->valueType()->isIntegral() && child->values().empty())
|
||||
intvar = true;
|
||||
return ChildrenToVisit::op1_and_op2;
|
||||
});
|
||||
if (!intvar)
|
||||
continue;
|
||||
// ensure that function name does not contain "assert"
|
||||
std::string funcname = tok->astParent()->previous()->str();
|
||||
std::transform(funcname.begin(), funcname.end(), funcname.begin(), [](int c) {
|
||||
|
|
|
@ -8835,6 +8835,13 @@ private:
|
|||
" ASSERT((int)((x & 0x01) >> 7));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #9905 - expression that does not use integer calculation at all
|
||||
check("void foo() {\n"
|
||||
" const std::string heading = \"Interval\";\n"
|
||||
" std::cout << std::setw(heading.length());\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkComparePointers() {
|
||||
|
|
Loading…
Reference in New Issue