Merge pull request #143 from simartin/ticket_4887

Fix Ticket 4887
This commit is contained in:
Daniel Marjamäki 2013-06-29 22:43:08 -07:00
commit 3571c874bc
2 changed files with 7 additions and 0 deletions

View File

@ -4119,6 +4119,8 @@ Token *Tokenizer::simplifyAddBracesPair(Token *tok, bool commandWithCondition)
tokBracesEnd=tokAfterCondition->link();
} else {
Token * tokEnd = simplifyAddBracesToCommand(tokAfterCondition);
if (!tokEnd) // Ticket #4887
return tok;
if (tokEnd->str()!="}") {
// Token does not end with brace
// Look for ; to add own closing brace after it

View File

@ -72,6 +72,7 @@ private:
TEST_CASE(garbageCode1);
TEST_CASE(garbageCode2); // #4300
TEST_CASE(garbageCode3); // #4869
TEST_CASE(garbageCode4); // #4887
TEST_CASE(simplifyFileAndLineMacro); // tokenize "return - __LINE__;"
@ -912,6 +913,10 @@ private:
tokenizeAndStringify("enum { D = 2 s ; struct y { x } ; } { s.a = C ; s.b = D ; }");
}
void garbageCode4() { // #4887
tokenizeAndStringify("void f ( ) { = a ; if ( 1 ) if = ( 0 ) ; }");
}
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
}