Fixed AST: Compile expression inside [] brackets of operator new. (#6193)

This commit is contained in:
PKEuS 2014-09-29 10:26:15 +02:00
parent 1495a411eb
commit 55b14853d0
2 changed files with 4 additions and 2 deletions

View File

@ -662,11 +662,13 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
if (tok->str() == "(" && Token::Match(tok->link(), ") %type%"))
tok = tok->link()->next();
state.op.push(tok);
while (Token::Match(tok, "%var%|*|&|<|[")) {
while (Token::Match(tok, "%var%|*|&|<")) {
if (tok->link())
tok = tok->link();
tok = tok->next();
}
if (tok->str() == "[")
compilePrecedence2(tok, state);
compileUnaryOp(tok2, state, nullptr);
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {
Token* tok2 = tok;

View File

@ -8352,7 +8352,7 @@ private:
void astnewdelete() const {
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
ASSERT_EQUALS("aintnew=", testAst("a = new int[4];"));
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);"));