Fixed #5088 (Token::Match called with varid 0. in libreoffice sd/source/ui/table/TableDesignPane.cxx)

This commit is contained in:
Robert Reif 2013-10-14 21:05:54 +02:00 committed by Daniel Marjamäki
parent cee40beee1
commit b41ab8a4d5
2 changed files with 23 additions and 2 deletions

View File

@ -4213,6 +4213,17 @@ Token *Tokenizer::simplifyAddBracesPair(Token *tok, bool commandWithCondition)
if (tokAfterCondition->str()=="{") {
// already surrounded by braces
tokBracesEnd=tokAfterCondition->link();
} else if (Token::Match(tokAfterCondition, "try {") &&
Token::Match(tokAfterCondition->linkAt(1), "} catch (")) {
tokAfterCondition->previous()->insertToken("{");
Token * tokOpenBrace = tokAfterCondition->previous();
Token * tokEnd = tokAfterCondition->linkAt(1)->linkAt(2)->linkAt(1);
tokEnd->insertToken("}");
Token * tokCloseBrace = tokEnd->next();
Token::createMutualLinks(tokOpenBrace, tokCloseBrace);
tokBracesEnd = tokCloseBrace;
} else {
Token * tokEnd = simplifyAddBracesToCommand(tokAfterCondition);
if (!tokEnd) // Ticket #4887

View File

@ -121,7 +121,8 @@ private:
TEST_CASE(whileAddBraces);
TEST_CASE(doWhileAddBraces);
TEST_CASE(forAddBraces);
TEST_CASE(forAddBraces1);
TEST_CASE(forAddBraces2); // #5088
TEST_CASE(pointers_condition);
@ -1459,7 +1460,7 @@ private:
}
}
void forAddBraces() {
void forAddBraces1() {
{
const char code[] = "void f() {\n"
" for(;;)\n"
@ -1491,6 +1492,15 @@ private:
}
}
void forAddBraces2() { // #5088
const char code[] = "void f() {\n"
" for(;;) try { } catch (...) { }\n"
"}";
const char expected[] = "void f ( ) {\n"
"for ( ; ; ) { try { } catch ( . . . ) { } }\n"
"}";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
}
std::string simplifyKnownVariables(const char code[]) {
errout.str("");