Fixed crash on garbage code #6859

This commit is contained in:
PKEuS 2015-07-22 13:32:34 +02:00
parent 860ea4fe48
commit ab1113fb16
2 changed files with 6 additions and 1 deletions

View File

@ -284,7 +284,7 @@ static bool isVariableChanged(const Token *start, const Token *end, const unsign
while (parent && parent->str() == ",")
parent = parent->astParent();
if (parent && parent->str() == "(") {
if (parent->astOperand1()->isName() && !parent->astOperand1()->function())
if (parent->astOperand1() && parent->astOperand1()->isName() && !parent->astOperand1()->function())
return true;
// TODO: check if function parameter is non-const reference etc..
}

View File

@ -144,6 +144,7 @@ private:
TEST_CASE(garbageCode102); // #6846
TEST_CASE(garbageCode103); // #6824
TEST_CASE(garbageCode104); // #6847
TEST_CASE(garbageCode105); // #6859
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -814,6 +815,10 @@ private:
ASSERT_THROW(checkCode("template < Types > struct S {> ( S < ) S >} { ( ) { } } ( ) { return S < void > ( ) } { ( )> >} { ( ) { } } ( ) { ( ) }"), InternalError);
}
void garbageCode105() { // #6859
checkCode("void foo (int i) { int a , for (a 1; a( < 4; a++) if (a) (b b++) (b);) n++; }");
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"