AST: better AST for placement new expression 'new (a) MyClass;'

This commit is contained in:
Daniel Marjamäki 2014-08-23 13:21:36 +02:00
parent 399e8e551e
commit 1060b30e52
2 changed files with 3 additions and 0 deletions

View File

@ -633,6 +633,8 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
} else if (state.cpp && Token::Match(tok, "new %var%|::|(")) {
Token* tok2 = tok;
tok = tok->next();
if (tok->str() == "(" && Token::Match(tok->link(), ") %type%"))
tok = tok->link()->next();
state.op.push(tok);
while (Token::Match(tok, "%var%|*|&|<|[")) {
if (tok->link())

View File

@ -10700,6 +10700,7 @@ private:
ASSERT_EQUALS("aintnew=", 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("adelete", testAst("delete a;"));
ASSERT_EQUALS("adelete", testAst("delete (a);"));
ASSERT_EQUALS("adelete", testAst("delete[] a;"));