Ticket #6713: Properly detect ternary operator in valueFlowForward.
This commit is contained in:
parent
ddc80246c2
commit
98e6dca4f2
|
@ -1043,6 +1043,8 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
// If a ? is seen and it's known that the condition is true/false..
|
// If a ? is seen and it's known that the condition is true/false..
|
||||||
else if (tok2->str() == "?") {
|
else if (tok2->str() == "?") {
|
||||||
const Token *condition = tok2->astOperand1();
|
const Token *condition = tok2->astOperand1();
|
||||||
|
if (!condition) // Ticket #6713
|
||||||
|
continue;
|
||||||
std::list<ValueFlow::Value>::const_iterator it;
|
std::list<ValueFlow::Value>::const_iterator it;
|
||||||
for (it = values.begin(); it != values.end(); ++it) {
|
for (it = values.begin(); it != values.end(); ++it) {
|
||||||
const std::map<unsigned int, MathLib::bigint> programMemory(getProgramMemory(tok2, varid, *it));
|
const std::map<unsigned int, MathLib::bigint> programMemory(getProgramMemory(tok2, varid, *it));
|
||||||
|
|
|
@ -94,6 +94,7 @@ private:
|
||||||
TEST_CASE(garbageCode53); // #6721
|
TEST_CASE(garbageCode53); // #6721
|
||||||
TEST_CASE(garbageCode54); // #6722
|
TEST_CASE(garbageCode54); // #6722
|
||||||
TEST_CASE(garbageCode55); // #6724
|
TEST_CASE(garbageCode55); // #6724
|
||||||
|
TEST_CASE(garbageCode56); // #6713
|
||||||
|
|
||||||
TEST_CASE(garbageValueFlow);
|
TEST_CASE(garbageValueFlow);
|
||||||
TEST_CASE(garbageSymbolDatabase);
|
TEST_CASE(garbageSymbolDatabase);
|
||||||
|
@ -535,6 +536,10 @@ private:
|
||||||
checkCode("() __attribute__((constructor)); { } { }");
|
checkCode("() __attribute__((constructor)); { } { }");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode56() { // #6713
|
||||||
|
checkCode("void foo() { int a = 0; int b = ???; }");
|
||||||
|
}
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
// #6089
|
// #6089
|
||||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||||
|
|
Loading…
Reference in New Issue