AST: improved handling of new
This commit is contained in:
parent
cca003490b
commit
b5faf3a0cc
|
@ -667,7 +667,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
}
|
}
|
||||||
if (tok->str() == "[")
|
if (tok->str() == "[" || tok->str() == "(")
|
||||||
compilePrecedence2(tok, state);
|
compilePrecedence2(tok, state);
|
||||||
compileUnaryOp(tok2, state, nullptr);
|
compileUnaryOp(tok2, state, nullptr);
|
||||||
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {
|
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {
|
||||||
|
|
|
@ -8370,9 +8370,10 @@ private:
|
||||||
void astnewdelete() const {
|
void astnewdelete() const {
|
||||||
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
|
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
|
||||||
ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];"));
|
ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];"));
|
||||||
ASSERT_EQUALS("aFoonew=", testAst("a = new Foo(bar);"));
|
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
|
||||||
ASSERT_EQUALS("aFoonew=", testAst("a = new Foo<bar>();"));
|
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
|
||||||
ASSERT_EQUALS("Xnew", testAst("new (a,b,c) X(1,2,3);"));
|
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);"));
|
ASSERT_EQUALS("adelete", testAst("delete (a);"));
|
||||||
ASSERT_EQUALS("adelete", testAst("delete[] a;"));
|
ASSERT_EQUALS("adelete", testAst("delete[] a;"));
|
||||||
|
|
Loading…
Reference in New Issue