Fixed #1424 (false positive: unintialized variable)
This commit is contained in:
parent
084b21494a
commit
ccef1d6eb5
|
@ -3196,6 +3196,9 @@ void Tokenizer::simplifyIfAddBraces()
|
|||
|
||||
bool innerIf = Token::simpleMatch(tempToken->next(), "if");
|
||||
|
||||
if (Token::simpleMatch(tempToken->next(), "do {"))
|
||||
tempToken = tempToken->tokAt(2)->link();
|
||||
|
||||
// insert close brace..
|
||||
// In most cases it would work to just search for the next ';' and insert a closing brace after it.
|
||||
// But here are special cases..
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
TEST_CASE(ifAddBraces9);
|
||||
TEST_CASE(ifAddBraces10);
|
||||
TEST_CASE(ifAddBraces11);
|
||||
TEST_CASE(ifAddBraces12);
|
||||
|
||||
TEST_CASE(whileAddBraces);
|
||||
TEST_CASE(doWhileAddBraces);
|
||||
|
@ -636,12 +637,19 @@ private:
|
|||
|
||||
void ifAddBraces11()
|
||||
{
|
||||
// ticket #1361
|
||||
const char code[] = "{ if (x) if (y) ; else ; }";
|
||||
const char expected[] = "{ if ( x ) { if ( y ) { ; } else { ; } } }";
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
|
||||
}
|
||||
|
||||
void ifAddBraces12()
|
||||
{
|
||||
// ticket #1424
|
||||
const char code[] = "{ if (x) do { } while(x); }";
|
||||
const char expected[] = "{ if ( x ) { do { } while ( x ) ; } }";
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
|
||||
}
|
||||
|
||||
void whileAddBraces()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue