Fixed #2616 (Segmentation fault with unknown macro)

This commit is contained in:
Daniel Marjamäki 2011-03-01 18:02:50 +01:00
parent a2d2d93958
commit db04d7b71e
2 changed files with 7 additions and 3 deletions

View File

@ -4600,9 +4600,6 @@ void Tokenizer::simplifyIfAddBraces()
continue;
}
if (tok->previous() && !Token::Match(tok->previous(), ";|{|}|else|)|:"))
continue;
if (Token::Match(tok, "if|for|while ("))
{
// don't add "{}" around ";" in "do {} while();" (#609)

View File

@ -80,6 +80,7 @@ private:
TEST_CASE(ifAddBraces12);
TEST_CASE(ifAddBraces13);
TEST_CASE(ifAddBraces14); // #2610 - segfault: if()<{}
TEST_CASE(ifAddBraces15); // #2616 - unknown macro before if
TEST_CASE(whileAddBraces);
TEST_CASE(doWhileAddBraces);
@ -861,6 +862,12 @@ private:
tokenizeAndStringify("if()<{}", false);
}
void ifAddBraces15()
{
// ticket #2616 - unknown macro before if
ASSERT_EQUALS("{ A if ( x ) { y ( ) ; } }", tokenizeAndStringify("{A if(x)y();}", false));
}
void whileAddBraces()
{