Fixed crash on garbage code (#7699)
This commit is contained in:
parent
d982dc5ffe
commit
e0838ff194
|
@ -362,7 +362,7 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value)
|
|||
setTokenValue(parent,value);
|
||||
}
|
||||
|
||||
else if (parent->str() == "?" && tok->str() == ":" && tok == parent->astOperand2()) {
|
||||
else if (parent->str() == "?" && tok->str() == ":" && tok == parent->astOperand2() && parent->astOperand1()) {
|
||||
// is condition always true/false?
|
||||
if (parent->astOperand1()->values.size() == 1U && parent->astOperand1()->values.front().isKnown()) {
|
||||
const ValueFlow::Value &condvalue = parent->astOperand1()->values.front();
|
||||
|
|
|
@ -232,6 +232,7 @@ private:
|
|||
TEST_CASE(garbageCode181);
|
||||
TEST_CASE(garbageCode182); // #4195
|
||||
TEST_CASE(garbageCode183); // #7505
|
||||
TEST_CASE(garbageCode184); // #7699
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
TEST_CASE(garbageAST);
|
||||
|
@ -1521,6 +1522,13 @@ private:
|
|||
ASSERT_THROW(checkCode("= { int } enum return { r = f() f(); }"), InternalError);
|
||||
}
|
||||
|
||||
void garbageCode184() { // #7699
|
||||
checkCode("unsigned int AquaSalSystem::GetDisplayScreenCount() {\n"
|
||||
" NSArray* pScreens = [NSScreen screens];\n"
|
||||
" return pScreens ? [pScreens count] : 1;\n"
|
||||
"}");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestGarbage)
|
||||
|
|
Loading…
Reference in New Issue