isConstVarExpression: Fix FPs when there is C++ cast
This commit is contained in:
parent
04d3672bde
commit
a73e989d1a
|
@ -1050,6 +1050,9 @@ bool isConstVarExpression(const Token *tok)
|
||||||
std::vector<const Token *> args = getArguments(tok);
|
std::vector<const Token *> args = getArguments(tok);
|
||||||
return std::all_of(args.begin(), args.end(), &isConstVarExpression);
|
return std::all_of(args.begin(), args.end(), &isConstVarExpression);
|
||||||
}
|
}
|
||||||
|
if (Token::simpleMatch(tok->previous(), "> (") && tok->astOperand2() && tok->astOperand1()->str().find("_cast") != std::string::npos) {
|
||||||
|
return isConstVarExpression(tok->astOperand2());
|
||||||
|
}
|
||||||
if (Token::Match(tok, "( %type%"))
|
if (Token::Match(tok, "( %type%"))
|
||||||
return isConstVarExpression(tok->astOperand1());
|
return isConstVarExpression(tok->astOperand1());
|
||||||
if (Token::Match(tok, "%cop%")) {
|
if (Token::Match(tok, "%cop%")) {
|
||||||
|
|
|
@ -7599,6 +7599,12 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void g(Foo *);\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" g(reinterpret_cast<Foo*>(0));\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void g(int);\n"
|
check("void g(int);\n"
|
||||||
"void f(int x) {\n"
|
"void f(int x) {\n"
|
||||||
" x = 0;\n"
|
" x = 0;\n"
|
||||||
|
|
Loading…
Reference in New Issue