valueflow: fix for ?:. the condition result is not a result of the ?.
This commit is contained in:
parent
fef251ac76
commit
b8e77c8005
|
@ -333,7 +333,7 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value)
|
|||
setTokenValue(parent,value);
|
||||
}
|
||||
|
||||
else if (parent->str() == "?") {
|
||||
else if (parent->str() == "?" && tok->str() == ":" && tok == parent->astOperand2()) {
|
||||
// is condition only depending on 1 variable?
|
||||
std::stack<const Token*> tokens;
|
||||
tokens.push(parent->astOperand1());
|
||||
|
|
|
@ -1202,6 +1202,13 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS(true, testValueOfX(code,3U,0));
|
||||
ASSERT_EQUALS(true, testValueOfX(code,3U,0x80));
|
||||
|
||||
code = "int f(int a) {\n"
|
||||
" int x = a & 0x80 ? 1 : 2;\n"
|
||||
" return x;\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code,3U,0));
|
||||
ASSERT_EQUALS(false, testValueOfX(code,3U,0x80));
|
||||
}
|
||||
|
||||
void valueFlowForLoop() {
|
||||
|
|
Loading…
Reference in New Issue