Fix 10624: FP knownConditionTrueFalse with pointer member and dynamic cast (#3598)
This commit is contained in:
parent
a0d633945e
commit
c14920218c
|
@ -598,7 +598,7 @@ static void setTokenValue(Token* tok, ValueFlow::Value value, const Settings* se
|
|||
// cast..
|
||||
if (const Token *castType = getCastTypeStartToken(parent)) {
|
||||
if (((tok->valueType() == nullptr && value.isImpossible()) || astIsPointer(tok)) &&
|
||||
value.valueType == ValueFlow::Value::ValueType::INT &&
|
||||
contains({ValueFlow::Value::ValueType::INT, ValueFlow::Value::ValueType::SYMBOLIC}, value.valueType) &&
|
||||
Token::simpleMatch(parent->astOperand1(), "dynamic_cast"))
|
||||
return;
|
||||
const ValueType &valueType = ValueType::parseDecl(castType, settings);
|
||||
|
|
|
@ -3914,6 +3914,19 @@ private:
|
|||
" if (m_PC->GetI() != I) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #10624
|
||||
check("struct Data {\n"
|
||||
" Base* PBase{};\n"
|
||||
"};\n"
|
||||
"void f(Data* BaseData) {\n"
|
||||
" Base* PObj = BaseData->PBase;\n"
|
||||
" if (PObj == nullptr)\n"
|
||||
" return;\n"
|
||||
" Derived* pD = dynamic_cast<Derived*>(PObj);\n"
|
||||
" if (pD) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueInfer() {
|
||||
|
|
Loading…
Reference in New Issue