Fix wrong syntax error
This commit is contained in:
parent
c5807459f9
commit
b30d463baf
|
@ -8471,10 +8471,10 @@ void Tokenizer::eraseDeadCode(Token *begin, const Token *end)
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Tokenizer::syntaxError(const Token *tok) const
|
||||
void Tokenizer::syntaxError(const Token *tok, const std::string code) const
|
||||
{
|
||||
printDebugOutput(0);
|
||||
throw InternalError(tok, "syntax error", InternalError::SYNTAX);
|
||||
throw InternalError(tok, code.empty() ? "syntax error" : "syntax error: " + code, InternalError::SYNTAX);
|
||||
}
|
||||
|
||||
void Tokenizer::unmatchedToken(const Token *tok) const
|
||||
|
@ -9021,8 +9021,8 @@ void Tokenizer::findGarbageCode() const
|
|||
|
||||
// Assign/increment/decrement literal
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok,"%num%|%str%|%char% %assign%|++|--"))
|
||||
syntaxError(tok);
|
||||
if (Token::Match(tok, "!!) %num%|%str%|%char% %assign%|++|--"))
|
||||
syntaxError(tok, tok->next()->str() + " " + tok->tokAt(2)->str());
|
||||
}
|
||||
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -597,7 +597,7 @@ private:
|
|||
public:
|
||||
|
||||
/** Syntax error */
|
||||
void syntaxError(const Token *tok) const;
|
||||
void syntaxError(const Token *tok, const std::string code = "") const;
|
||||
|
||||
/** Syntax error. Unmatched character. */
|
||||
void unmatchedToken(const Token *tok) const;
|
||||
|
|
|
@ -1656,6 +1656,7 @@ private:
|
|||
void syntaxErrorFuzzerCliType1() {
|
||||
ASSERT_THROW(checkCode("void f(){x=0,return return''[]()}"), InternalError);
|
||||
ASSERT_THROW(checkCode("void f(){x='0'++'0'(return)[];}"), InternalError); // #9063
|
||||
checkCode("void f(){*(int *)42=0;}");
|
||||
ASSERT_THROW(checkCode("void f() { x= 'x' > typedef name5 | ( , ;){ } (); }"), InternalError); // #9067
|
||||
ASSERT_THROW(checkCode("void f() { x= {}( ) ( 'x')[ ] (); }"), InternalError); // #9068
|
||||
ASSERT_THROW(checkCode("void f() { x= y{ } name5 y[ ] + y ^ name5 ^ name5 for ( ( y y y && y y y && name5 ++ int )); }"), InternalError); // #9069
|
||||
|
|
Loading…
Reference in New Issue