Proper simplify delete a,b
This commit is contained in:
parent
9846ff10b2
commit
e8f0abf259
|
@ -8726,9 +8726,8 @@ void Tokenizer::simplifyComma()
|
||||||
|
|
||||||
if (Token::Match(tok->tokAt(-2), "delete %name% , %name% ;") &&
|
if (Token::Match(tok->tokAt(-2), "delete %name% , %name% ;") &&
|
||||||
tok->next()->varId() != 0) {
|
tok->next()->varId() != 0) {
|
||||||
// Handle "delete a, b;"
|
// Handle "delete a, b;" - convert to delete a; b;
|
||||||
tok->str(";");
|
tok->str(";");
|
||||||
tok->insertToken("delete");
|
|
||||||
} else if (!inReturn && tok->tokAt(-2)) {
|
} else if (!inReturn && tok->tokAt(-2)) {
|
||||||
bool replace = false;
|
bool replace = false;
|
||||||
for (Token *tok2 = tok->previous(); tok2; tok2 = tok2->previous()) {
|
for (Token *tok2 = tok->previous(); tok2; tok2 = tok2->previous()) {
|
||||||
|
|
|
@ -1796,7 +1796,17 @@ private:
|
||||||
" char *a, *b;\n"
|
" char *a, *b;\n"
|
||||||
" delete a, b;\n"
|
" delete a, b;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS("void foo ( ) { char * a ; char * b ; delete a ; delete b ; }", tok(code));
|
ASSERT_EQUALS("void foo ( ) { char * a ; char * b ; delete a ; b ; }", tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" char *a, *b;\n"
|
||||||
|
" if (x) \n"
|
||||||
|
" delete a, b;\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS("void foo ( ) { char * a ; char * b ; if ( x ) { delete a ; b ; } }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue