diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 245ac9cff..31ab4b5f9 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -294,12 +294,13 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti if (!parent) return; - // Cast.. + // TODO: Cast.. + /* if (parent->str() == "(" && tok == parent->link()->next()) { setTokenValue(parent,value,settings); - } + } else .. */ - else if (parent->str() == ":") { + if (parent->str() == ":") { setTokenValue(parent,value,settings); } diff --git a/test/testother.cpp b/test/testother.cpp index ffbdeaa8d..3c2b82545 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -264,11 +264,6 @@ private: " cout << 42 / (float)0;\n" "}"); ASSERT_EQUALS("", errout.str()); - - check("void foo() {\n" - " cout << 42 / (int)0;\n" - "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) Division by zero.\n", errout.str()); } void zeroDiv2() { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 6813c2ffc..7e703dabf 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -371,6 +371,10 @@ private: ASSERT_EQUALS(0, valueOfTok("3 < (a ? b : 2);", "<").intvalue); ASSERT_EQUALS(0, valueOfTok("3 <= (a ? b : 2);", "<=").intvalue); + ASSERT(tokenValues("(UNKNOWN_TYPE)123;","(").empty()); + ASSERT(tokenValues("(unsigned char)~0;", "(").empty()); // TODO: should get value 255 + ASSERT(tokenValues("(int)0;", "(").empty()); // TODO: should get value 0 + // Don't calculate if there is UB ASSERT(tokenValues(";-1<<10;","<<").empty()); ASSERT(tokenValues(";10<<-1;","<<").empty());