Fixed AST: Compile expression inside [] brackets of operator new. (#6193)
This commit is contained in:
parent
1495a411eb
commit
55b14853d0
|
@ -662,11 +662,13 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
|
||||||
if (tok->str() == "(" && Token::Match(tok->link(), ") %type%"))
|
if (tok->str() == "(" && Token::Match(tok->link(), ") %type%"))
|
||||||
tok = tok->link()->next();
|
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())
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
}
|
}
|
||||||
|
if (tok->str() == "[")
|
||||||
|
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%|*|&|::|(|[")) {
|
||||||
Token* tok2 = tok;
|
Token* tok2 = tok;
|
||||||
|
|
|
@ -8352,7 +8352,7 @@ private:
|
||||||
|
|
||||||
void astnewdelete() const {
|
void astnewdelete() const {
|
||||||
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
|
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("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("Xnew", testAst("new (a,b,c) X(1,2,3);"));
|
||||||
|
|
Loading…
Reference in New Issue