Fixed #498 (Tokenizer: simplify 'goto')

This commit is contained in:
Daniel Marjamäki 2009-08-26 18:46:56 +02:00
parent 89f9645174
commit f94aab35e7
2 changed files with 12 additions and 2 deletions

View File

@ -3121,7 +3121,12 @@ void Tokenizer::simplifyGoto()
for (Token *tok = _tokens; tok; tok = (tok ? tok->next() : NULL))
{
if (tok->str() == "{")
++indentlevel;
{
if (beginfunction == 0 && indentlevel == 0 && tok->link())
tok = tok->link();
else
++indentlevel;
}
else if (tok->str() == "}")
{
@ -3144,7 +3149,7 @@ void Tokenizer::simplifyGoto()
else if (Token::Match(tok, "goto %var% ;"))
gotos.push_back(tok);
else if (indentlevel == 1 && Token::Match(tok, "%var% :"))
else if (indentlevel == 1 && Token::Match(tok->previous(), "[};] %var% :"))
{
// Is this label at the end..
bool end = false;

View File

@ -1261,6 +1261,11 @@ private:
ASSERT_EQUALS(expect, tok(code));
}
{
const char code[] = "class NoLabels { bool varOne : 1 ; bool varTwo : 1 ; } ;";
ASSERT_EQUALS(code, tok(code));
}
}
};