ValueFlow: Fixed nullpointer FP warning in checksizeof

This commit is contained in:
Daniel Marjamäki 2014-08-11 16:21:20 +02:00
parent 263582ddbd
commit 970fda9e79
2 changed files with 21 additions and 0 deletions

View File

@ -825,6 +825,10 @@ static bool valueFlowForward(Token * const startToken,
errorLogger,
tok2,
"no simplification of " + tok2->str() + " within " + (Token::Match(parent,"[?:]") ? "?:" : parent->str()) + " expression");
while (parent && parent->str() != "(")
parent = parent->astParent();
if (parent)
tok2 = const_cast<Token*>(parent->link());
continue;
}

View File

@ -940,6 +940,23 @@ private:
"}";
ASSERT_EQUALS(true, testValueOfX(code, 3U, 4));
// protected usage with &&
code = "void f(const Token* x) {\n"
" if (x) {}\n"
" for (; x && \n"
" x->str() != y; x = x->next()) {}\n"
"}";
ASSERT_EQUALS(true, testValueOfX(code, 3U, 0));
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
code = "void f(const Token* x) {\n"
" if (x) {}\n"
" if (x && \n"
" x->str() != y) {}\n"
"}";
TODO_ASSERT_EQUALS(true, false, testValueOfX(code, 3U, 0));
ASSERT_EQUALS(false, testValueOfX(code, 4U, 0));
// TODO: float
code = "void f(float x) {\n"
" if (x == 0.5) {}\n"