Tokenizer: Detect more syntax errors when operator does not have operands

This commit is contained in:
Daniel Marjamäki 2019-11-14 21:18:31 +01:00
parent dbbb7f544a
commit 7e0fc4fb00
2 changed files with 4 additions and 2 deletions

View File

@ -9439,6 +9439,8 @@ void Tokenizer::findGarbageCode() const
if (!Token::Match(tok->next(), "%name%|*|~"))
syntaxError(tok, tok->strAt(-1) + " " + tok->str() + " " + tok->strAt(1));
}
if (Token::Match(tok, "[!|+-/%^~] )|]"))
syntaxError(tok);
}
// ternary operator without :

View File

@ -1010,7 +1010,7 @@ private:
}
void garbageCode132() { // #7022
checkCode("() () { } { () () ({}) i() } void i(void(*ptr) ()) { ptr(!) () }");
ASSERT_THROW(checkCode("() () { } { () () ({}) i() } void i(void(*ptr) ()) { ptr(!) () }"), InternalError);
}
void garbageCode133() {
@ -1247,7 +1247,7 @@ private:
}
void garbageCode159() { // #7119
checkCode("({}typedef typename x;typename x!){({{}()})}"); // don't hang
ASSERT_THROW(checkCode("({}typedef typename x;typename x!){({{}()})}"), InternalError);
}
void garbageCode160() { // #7190