Merge pull request #835 from JIghtuse/master
Fixed #7139 (ValueFlow: Missed shift operation in for expression)
This commit is contained in:
commit
4f922f56cb
|
@ -1929,6 +1929,10 @@ static void execute(const Token *expr,
|
||||||
*result = result1 / result2;
|
*result = result1 / result2;
|
||||||
else if (expr->str() == "%")
|
else if (expr->str() == "%")
|
||||||
*result = result1 % result2;
|
*result = result1 % result2;
|
||||||
|
else if (expr->str() == "<<")
|
||||||
|
*result = result1 << result2;
|
||||||
|
else if (expr->str() == ">>")
|
||||||
|
*result = result1 >> result2;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (expr->str() == "&&") {
|
else if (expr->str() == "&&") {
|
||||||
|
|
|
@ -1968,6 +1968,19 @@ private:
|
||||||
value = valueOfTok(code, "&");
|
value = valueOfTok(code, "&");
|
||||||
ASSERT_EQUALS(0, value.intvalue);
|
ASSERT_EQUALS(0, value.intvalue);
|
||||||
ASSERT(value.isKnown());
|
ASSERT(value.isKnown());
|
||||||
|
|
||||||
|
// Ticket #7139
|
||||||
|
// "<<" in third expression of for
|
||||||
|
code = "void f(void) {\n"
|
||||||
|
" int bit, x;\n"
|
||||||
|
" for (bit = 1, x = 0; bit < 128; bit = bit << 1, x++) {\n"
|
||||||
|
" z = x;\n" // <- known value [0..6]
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(true, testValueOfX(code, 4U, 0));
|
||||||
|
ASSERT_EQUALS(true, testValueOfX(code, 4U, 6));
|
||||||
|
ASSERT_EQUALS(false, testValueOfX(code, 4U, 7));
|
||||||
|
ASSERT(value.isKnown());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue