Fixed #9736 (False positive: knownArgument in assert calls)
This commit is contained in:
parent
43b58dbc9e
commit
c86cfdaa50
|
@ -3041,6 +3041,13 @@ void CheckOther::checkKnownArgument()
|
|||
tok2 = tok2->astOperand2();
|
||||
if (isVariableExpression(tok2))
|
||||
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) {
|
||||
return std::tolower(c);
|
||||
});
|
||||
if (funcname.find("assert") != std::string::npos)
|
||||
continue;
|
||||
knownArgumentError(tok, tok->astParent()->previous(), &tok->values().front());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8423,6 +8423,13 @@ private:
|
|||
" g(y.x);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// allow known argument value in assert call
|
||||
check("void g(int);\n"
|
||||
"void f(int x) {\n"
|
||||
" ASSERT((int)((x & 0x01) >> 7));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkComparePointers() {
|
||||
|
|
Loading…
Reference in New Issue