Tokenizer::simplifyRedundantParentheses: dont remove parentheses in 'void * operator new(SIZE_TYPE, int);'

This commit is contained in:
Daniel Marjamäki 2014-10-11 09:18:43 +02:00
parent e6708c1ae2
commit dd6ae3033f
2 changed files with 7 additions and 1 deletions

View File

@ -7162,7 +7162,7 @@ bool Tokenizer::simplifyRedundantParentheses()
ret = true;
}
if (isCPP() && Token::simpleMatch(tok->previous(), "new (") && Token::Match(tok->link(), ") [;,{}[]")) {
if (isCPP() && Token::Match(tok->tokAt(-2), "[;{}=(] new (") && Token::Match(tok->link(), ") [;,{}[]")) {
// Remove the parentheses in "new (type)" constructs
tok->link()->deleteThis();
tok->deleteThis();

View File

@ -3465,6 +3465,12 @@ private:
static char exp[] = "list < int > * f [ 1 ] = { new list < int > } ;";
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
}
// don't remove parentheses in operator new overload
{
static char code[] = "void *operator new(__SIZE_TYPE__, int);";
static char exp[] = "void * operatornew ( __SIZE_TYPE__ , int ) ;";
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
}
}
void tokenize_double() {