ValueFlow: inner and outer function return values
This commit is contained in:
parent
77cd6c194f
commit
8a0f3009ff
|
@ -2491,7 +2491,7 @@ static bool isKnown(const Token * tok)
|
|||
|
||||
static void valueFlowFunctionReturn(TokenList *tokenlist, ErrorLogger *errorLogger, const Settings *settings)
|
||||
{
|
||||
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
|
||||
for (Token *tok = tokenlist->back(); tok; tok = tok->previous()) {
|
||||
if (tok->str() != "(" || !tok->astOperand1() || !tok->astOperand1()->function())
|
||||
continue;
|
||||
|
||||
|
|
|
@ -1783,6 +1783,15 @@ private:
|
|||
"void f() { x = 1 * one(); }";
|
||||
ASSERT_EQUALS(1, valueOfTok(code, "*").intvalue);
|
||||
ASSERT_EQUALS(true, valueOfTok(code, "*").isKnown());
|
||||
|
||||
code = "int add(int x, int y) {\n"
|
||||
" return x+y;\n"
|
||||
"}\n"
|
||||
"void f2() {\n"
|
||||
" x = 1 * add(1,add(2,3));\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(6, valueOfTok(code, "*").intvalue);
|
||||
ASSERT_EQUALS(true, valueOfTok(code, "*").isKnown());
|
||||
}
|
||||
|
||||
void valueFlowFunctionDefaultParameter() {
|
||||
|
|
Loading…
Reference in New Issue