Fixed crash on garbage code (#8317)

This commit is contained in:
PKEuS 2018-01-07 12:52:28 +01:00
parent eb58df236e
commit 817f66d74d
2 changed files with 7 additions and 0 deletions

View File

@ -459,6 +459,8 @@ void CheckAutoVariables::returnReference()
for (const Token *tok2 = scope->classStart->next(); tok2 && tok2 != scope->classEnd; tok2 = tok2->next()) {
if (!tok2->scope()->isExecutable()) {
tok2 = tok2->scope()->classEnd;
if (!tok2)
break;
continue;
}

View File

@ -219,6 +219,7 @@ private:
TEST_CASE(garbageCode186); // #8151
TEST_CASE(garbageCode187);
TEST_CASE(garbageCode188);
TEST_CASE(garbageCode189); // #8317
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
TEST_CASE(garbageAST);
@ -1437,6 +1438,10 @@ private:
ASSERT_THROW(checkCode("{z r(){(){for(;<(x);){if(0==0)}}}}"), InternalError);
}
void garbageCode189() { // #8317
checkCode("t&n(){()()[](){()}}$");
}
void syntaxErrorFirstToken() {
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858