One more fix for #6811 (ValueFlow: result of ?:)

This commit is contained in:
Daniel Marjamäki 2015-07-02 20:52:04 +02:00
parent c751039612
commit 7e1ddea653
2 changed files with 7 additions and 3 deletions

View File

@ -355,10 +355,8 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value)
ValueFlow::Value v(value);
if (!variables.empty()) {
if (!variables.empty())
v.varId = *(variables.begin());
return;
}
setTokenValue(parent, v);
}

View File

@ -260,6 +260,12 @@ private:
ASSERT_EQUALS(2, values.front().intvalue);
ASSERT_EQUALS(3, values.back().intvalue);
code = "void f(int a) { x = a ? 2 : 3; }\n";
values = tokenValues(code,"?");
ASSERT_EQUALS(2U, values.size());
ASSERT_EQUALS(2, values.front().intvalue);
ASSERT_EQUALS(3, values.back().intvalue);
// function call => calculation
code = "void f(int x) {\n"
" a = x + 8;\n"