diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index b8b2f11cc..53795bc66 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -182,6 +182,7 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger, { std::list argvalues; for (Token *tok = tokenlist->front(); tok; tok = tok->next()) { + // passing value(s) to function if (Token::Match(tok, "[(,] %var% [,)]") && !tok->next()->values.empty()) argvalues = tok->next()->values; else if (Token::Match(tok, "[(,] %num% [,)]")) { @@ -226,7 +227,7 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger, } else if (tok2->varId() == varid2 || tok2->str() == "{") { if (settings->debugwarnings) bailout(tokenlist, errorLogger, tok2, "parameter " + arg->nameToken()->str()); - continue; + break; } } } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index d04587dee..d8a04f6cf 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -136,6 +136,16 @@ private: " if (x==0){}\n" "}"; ASSERT_EQUALS(true, testValueOfX(code, 1U, 0)); + + code = "void f1(int x) {\n" + " if (x == 0) return;\n" + " int y = 1234 / x;\n" + "}\n" + "\n" + "void f2() {\n" + " f1(0);\n" + "}"; + ASSERT_EQUALS(false, testValueOfX(code, 3U, 0)); } };