Tokenizer::simplifyGoto: Don't simplify 'goto' inside unhandled macro calls. Ticket: #2348

This commit is contained in:
Daniel Marjamäki 2010-12-23 22:03:58 +01:00
parent 472ecd8805
commit 18fd12006a
2 changed files with 12 additions and 0 deletions

View File

@ -6775,6 +6775,11 @@ void Tokenizer::simplifyGoto()
}
}
else if (indentlevel > 0 && tok->str() == "(")
{
tok = tok->link();
}
else if (indentlevel == 0 && Token::Match(tok, ") const| {"))
{
gotos.clear();

View File

@ -147,6 +147,7 @@ private:
// Simplify goto..
TEST_CASE(goto1);
TEST_CASE(goto2);
// Simplify nested strcat() calls
TEST_CASE(strcat1);
@ -2778,6 +2779,12 @@ private:
}
}
void goto2()
{
// Don't simplify goto inside function call (macro)
const char code[] = "void f ( ) { slist_iter ( if ( a ) { goto dont_write ; } dont_write : ; x ( ) ; ) ; }";
ASSERT_EQUALS(code, tok(code));
}
void strcat1()
{