Fixed #1985 (false positive: syntax error in try catch-block with for()-loop inside)
This commit is contained in:
parent
02088443f9
commit
57523574ef
|
@ -1792,6 +1792,18 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::s
|
|||
tok = tok->link();
|
||||
}
|
||||
|
||||
// skip executing scopes (ticket #1985)..
|
||||
if (Token::simpleMatch(tok, "try {"))
|
||||
{
|
||||
tok = tok->next()->link();
|
||||
while (Token::simpleMatch(tok, "} catch ("))
|
||||
{
|
||||
tok = tok->tokAt(2)->link();
|
||||
if (Token::simpleMatch(tok, ") {"))
|
||||
tok = tok->next()->link();
|
||||
}
|
||||
}
|
||||
|
||||
// not start of statement?
|
||||
if (tok->previous() && !Token::Match(tok, "[;{}]"))
|
||||
continue;
|
||||
|
|
|
@ -3691,6 +3691,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// ok code (ticket #1985)..
|
||||
{
|
||||
errout.str("");
|
||||
std::istringstream istr("void f()\n"
|
||||
"try { ;x<y; }");
|
||||
Tokenizer tokenizer(0, this);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// bad code.. missing ">"
|
||||
{
|
||||
errout.str("");
|
||||
|
|
Loading…
Reference in New Issue