Fixed #9068 (crash on invalid code)
This commit is contained in:
parent
ce11778a20
commit
c262aeffdd
|
@ -8993,6 +8993,14 @@ static const Token *findUnmatchedTernaryOp(const Token * const begin, const Toke
|
|||
|
||||
void Tokenizer::findGarbageCode() const
|
||||
{
|
||||
// initialization: = {
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (!Token::simpleMatch(tok, "= {"))
|
||||
continue;
|
||||
if (Token::simpleMatch(tok->linkAt(1), "} ("))
|
||||
syntaxError(tok->linkAt(1));
|
||||
}
|
||||
|
||||
// Inside [] there can't be ; or various keywords
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (tok->str() != "[")
|
||||
|
|
|
@ -1656,6 +1656,7 @@ private:
|
|||
ASSERT_THROW(checkCode("void f(){x=0,return return''[]()}"), InternalError);
|
||||
ASSERT_THROW(checkCode("void f(){x='0'++'0'(return)[];}"), InternalError); // #9063
|
||||
ASSERT_THROW(checkCode("void f() { x= 'x' > typedef name5 | ( , ;){ } (); }"), InternalError); // #9067
|
||||
ASSERT_THROW(checkCode("void f() { x= {}( ) ( 'x')[ ] (); }"), InternalError); // #9068
|
||||
}
|
||||
|
||||
void enumTrailingComma() {
|
||||
|
|
Loading…
Reference in New Issue