AST: better AST for placement new expression 'new (a) MyClass;'
This commit is contained in:
parent
399e8e551e
commit
1060b30e52
|
@ -633,6 +633,8 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
|
||||||
} else if (state.cpp && Token::Match(tok, "new %var%|::|(")) {
|
} else if (state.cpp && Token::Match(tok, "new %var%|::|(")) {
|
||||||
Token* tok2 = tok;
|
Token* tok2 = tok;
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
if (tok->str() == "(" && Token::Match(tok->link(), ") %type%"))
|
||||||
|
tok = tok->link()->next();
|
||||||
state.op.push(tok);
|
state.op.push(tok);
|
||||||
while (Token::Match(tok, "%var%|*|&|<|[")) {
|
while (Token::Match(tok, "%var%|*|&|<|[")) {
|
||||||
if (tok->link())
|
if (tok->link())
|
||||||
|
|
|
@ -10700,6 +10700,7 @@ private:
|
||||||
ASSERT_EQUALS("aintnew=", testAst("a = new int[4];"));
|
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("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);"));
|
ASSERT_EQUALS("adelete", testAst("delete (a);"));
|
||||||
ASSERT_EQUALS("adelete", testAst("delete[] a;"));
|
ASSERT_EQUALS("adelete", testAst("delete[] a;"));
|
||||||
|
|
Loading…
Reference in New Issue