From 228206f55687dd4766ec6d89277f8a05897c9e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 15 Oct 2014 16:34:03 +0200 Subject: [PATCH] Fixed #6067 (ValueFlow: subfunction, condition with && or ||) --- lib/valueflow.cpp | 2 +- test/testvalueflow.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index eba7d7c52..ce0abbf75 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1554,7 +1554,7 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger, if (Token::Match(tok2, "%varid% !!=", varid2)) { for (std::list::const_iterator val = argvalues.begin(); val != argvalues.end(); ++val) setTokenValue(const_cast(tok2), *val); - } else if (Token::Match(tok2, "{|?")) { + } else if (Token::Match(tok2, "%oror%|&&|{|?")) { if (settings->debugwarnings) bailout(tokenlist, errorLogger, tok2, "parameter " + arg->name() + ", at '" + tok2->str() + "'"); break; diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 6ffdc052c..50b6149ad 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1279,6 +1279,14 @@ private: ASSERT_EQUALS(true, testValueOfX(code, 2U, 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 code = "void f1(float x) {\n" " return 1.0 / x;\n"