AST: improved handling of new

This commit is contained in:
Daniel Marjamäki 2014-10-10 10:37:54 +02:00
parent cca003490b
commit b5faf3a0cc
2 changed files with 5 additions and 4 deletions

View File

@ -667,7 +667,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
tok = tok->link();
tok = tok->next();
}
if (tok->str() == "[")
if (tok->str() == "[" || tok->str() == "(")
compilePrecedence2(tok, state);
compileUnaryOp(tok2, state, nullptr);
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {

View File

@ -8370,9 +8370,10 @@ private:
void astnewdelete() const {
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];"));
ASSERT_EQUALS("aFoonew=", testAst("a = new Foo(bar);"));
ASSERT_EQUALS("aFoonew=", testAst("a = new Foo<bar>();"));
ASSERT_EQUALS("Xnew", testAst("new (a,b,c) X(1,2,3);"));
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
ASSERT_EQUALS("aFoo(new=", testAst("a = new Foo<bar>();"));
ASSERT_EQUALS("X12,3,(new", testAst("new (a,b,c) X(1,2,3);"));
ASSERT_EQUALS("adelete", testAst("delete a;"));
ASSERT_EQUALS("adelete", testAst("delete (a);"));
ASSERT_EQUALS("adelete", testAst("delete[] a;"));