Fixed #1865 (Tokenizer::simplifyRedundantParantheses: wrong handling of 'operator delete')
This commit is contained in:
parent
7ef0296f97
commit
d4d0bc050a
|
@ -5735,8 +5735,9 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if ((Token::simpleMatch(tok->previous(), "delete (") && Token::Match(tok->link(), ") ;|,")) ||
|
||||
(Token::simpleMatch(tok->previous(), "; (") && Token::Match(tok->link(), ") ;")))
|
||||
if (!Token::simpleMatch(tok->tokAt(-2), "operator delete") &&
|
||||
Token::Match(tok->previous(), "delete|; (") &&
|
||||
Token::Match(tok->link(), ") ;|,"))
|
||||
{
|
||||
tok->link()->deleteThis();
|
||||
tok->deleteThis();
|
||||
|
|
|
@ -165,13 +165,14 @@ private:
|
|||
|
||||
TEST_CASE(simplify_function_parameters);
|
||||
|
||||
TEST_CASE(removeParantheses1); // Ticket #61
|
||||
TEST_CASE(removeParantheses1); // Ticket #61
|
||||
TEST_CASE(removeParantheses2);
|
||||
TEST_CASE(removeParantheses3);
|
||||
TEST_CASE(removeParantheses4); // Ticket #390
|
||||
TEST_CASE(removeParantheses5); // Ticket #392
|
||||
TEST_CASE(removeParantheses6);
|
||||
TEST_CASE(removeParantheses7);
|
||||
TEST_CASE(removeParantheses8); // Ticket #1865
|
||||
|
||||
TEST_CASE(tokenize_double);
|
||||
TEST_CASE(tokenize_strings);
|
||||
|
@ -3014,6 +3015,20 @@ private:
|
|||
ASSERT_EQUALS(" ; delete p ; ( p ) = 0 ;", ostr.str());
|
||||
}
|
||||
|
||||
void removeParantheses8()
|
||||
{
|
||||
const char code[] = "struct foo {\n"
|
||||
" void operator delete(void *obj, size_t sz);\n"
|
||||
"}\n";
|
||||
const std::string actual(tokenizeAndStringify(code));
|
||||
|
||||
const char expected[] = "struct foo {\n"
|
||||
"void operator delete ( void * obj , size_t sz ) ;\n"
|
||||
"}";
|
||||
|
||||
ASSERT_EQUALS(expected, actual);
|
||||
}
|
||||
|
||||
void tokenize_double()
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
|
|
Loading…
Reference in New Issue