File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -800,8 +800,7 @@ static void setTokenValue(Token* tok,
800800
801801 // cast..
802802 if (const Token *castType = getCastTypeStartToken (parent)) {
803- if (((tok->valueType () == nullptr && value.isImpossible ()) || astIsPointer (tok)) &&
804- contains ({ValueFlow::Value::ValueType::INT, ValueFlow::Value::ValueType::SYMBOLIC}, value.valueType ) &&
803+ if (contains ({ValueFlow::Value::ValueType::INT, ValueFlow::Value::ValueType::SYMBOLIC}, value.valueType ) &&
805804 Token::simpleMatch (parent->astOperand1 (), " dynamic_cast" ))
806805 return ;
807806 const ValueType &valueType = ValueType::parseDecl (castType, settings);
Original file line number Diff line number Diff line change @@ -667,6 +667,17 @@ class TestCondition : public TestFixture {
667667 " }" );
668668 ASSERT_EQUALS (" " , errout.str ());
669669
670+ check (" class B { virtual void v() {} };\n " // #11037
671+ " class D1 : public B {};\n "
672+ " class D2 : public B {};\n "
673+ " void f(const std::shared_ptr<B>&p) {\n "
674+ " const auto d1 = dynamic_cast<D1*>(p.get());\n "
675+ " const auto d2 = dynamic_cast<D2*>(p.get());\n "
676+ " if (d1) {}\n "
677+ " else if (d2) {}\n "
678+ " }\n " );
679+ ASSERT_EQUALS (" " , errout.str ());
680+
670681 check (" void f(int x) {\n " // #6482
671682 " if (x & 1) {}\n "
672683 " else if (x == 0) {}\n "
You can’t perform that action at this time.
0 commit comments