Fixed #6067 (ValueFlow: subfunction, condition with && or ||)

This commit is contained in:
Daniel Marjamäki 2014-10-15 16:34:03 +02:00
parent 17cab08cba
commit 228206f556
2 changed files with 9 additions and 1 deletions

View File

@ -1554,7 +1554,7 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger,
if (Token::Match(tok2, "%varid% !!=", varid2)) { if (Token::Match(tok2, "%varid% !!=", varid2)) {
for (std::list<ValueFlow::Value>::const_iterator val = argvalues.begin(); val != argvalues.end(); ++val) for (std::list<ValueFlow::Value>::const_iterator val = argvalues.begin(); val != argvalues.end(); ++val)
setTokenValue(const_cast<Token*>(tok2), *val); setTokenValue(const_cast<Token*>(tok2), *val);
} else if (Token::Match(tok2, "{|?")) { } else if (Token::Match(tok2, "%oror%|&&|{|?")) {
if (settings->debugwarnings) if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "parameter " + arg->name() + ", at '" + tok2->str() + "'"); bailout(tokenlist, errorLogger, tok2, "parameter " + arg->name() + ", at '" + tok2->str() + "'");
break; break;

View File

@ -1279,6 +1279,14 @@ private:
ASSERT_EQUALS(true, testValueOfX(code, 2U, 0)); ASSERT_EQUALS(true, testValueOfX(code, 2U, 0));
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0)); ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
code = "void f1(int *x) {\n"
" if (x &&\n"
" *x) {}\n"
"}\n"
"void f2() { f1(0); }";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 0));
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
// #5861 - fp with float // #5861 - fp with float
code = "void f1(float x) {\n" code = "void f1(float x) {\n"
" return 1.0 / x;\n" " return 1.0 / x;\n"