Fix crash when checking re2c textfile

This commit is contained in:
Daniel Marjamäki 2019-03-26 20:51:41 +01:00
parent 7c6f21a158
commit c77f31319d
2 changed files with 5 additions and 2 deletions

View File

@ -9154,8 +9154,10 @@ void Tokenizer::findGarbageCode() const
syntaxError(list.back());
if (list.back()->str() == ")" && !Token::Match(list.back()->link()->previous(), "%name% ("))
syntaxError(list.back());
if (Token::Match(list.back(), "void|char|short|int|long|float|double|const|volatile|static|inline|struct|class|enum|union|template|sizeof|case|break|continue|typedef"))
syntaxError(list.back());
for (const Token *end = list.back(); end && end->isName(); end = end->previous()) {
if (Token::Match(end, "void|char|short|int|long|float|double|const|volatile|static|inline|struct|class|enum|union|template|sizeof|case|break|continue|typedef"))
syntaxError(list.back());
}
if ((list.back()->str()==")" || list.back()->str()=="}") && list.back()->previous() && list.back()->previous()->isControlFlowKeyword())
syntaxError(list.back()->previous());

View File

@ -1638,6 +1638,7 @@ private:
ASSERT_THROW(checkCode("int"), InternalError);
ASSERT_THROW(checkCode("struct A :\n"), InternalError); // #2591
ASSERT_THROW(checkCode("{} const const\n"), InternalError); // #2637
ASSERT_THROW(checkCode("re2c: error: line 14, column 4: can only difference char sets"), InternalError);
// ASSERT_THROW( , InternalError)
}