Fixed #1817 (False positive: Resource leak (casting))

This commit is contained in:
Daniel Marjamäki 2010-07-05 13:16:33 +02:00
parent c811acaa50
commit b173d5f117
2 changed files with 16 additions and 1 deletions

View File

@ -4334,7 +4334,7 @@ void Tokenizer::simplifyCasts()
}
}
if (Token::Match(tok->next(), "dynamic_cast|reinterpret_cast|const_cast|static_cast <"))
while (Token::Match(tok->next(), "dynamic_cast|reinterpret_cast|const_cast|static_cast <"))
{
Token *tok2 = tok->next();
unsigned int level = 0;
@ -4359,6 +4359,14 @@ void Tokenizer::simplifyCasts()
Token::eraseTokens(tok, tok2->tokAt(2));
closeBracket->deleteThis();
}
else
{
break;
}
}
else
{
break;
}
}
}

View File

@ -57,6 +57,7 @@ private:
TEST_CASE(removeCast2);
TEST_CASE(removeCast3);
TEST_CASE(removeCast4);
TEST_CASE(removeCast5);
TEST_CASE(inlineasm);
@ -428,6 +429,12 @@ private:
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
}
void removeCast5()
{
// ticket #1817
ASSERT_EQUALS("a . data = f ;", tokenizeAndStringify("a->data = reinterpret_cast<void*>(static_cast<intptr_t>(f));", true));
}
void inlineasm()
{
ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";asm { mov ax,bx };"));