AST: fixed ast for 'a(new A(1)), b(new B(2))'
This commit is contained in:
parent
649e2dfa97
commit
f72a8d3f15
|
@ -659,15 +659,20 @@ 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* newtok = tok;
|
Token* newtok = tok;
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
bool innertype = false;
|
||||||
if (tok->str() == "(") {
|
if (tok->str() == "(") {
|
||||||
if (Token::Match(tok, "( &| %var%") && Token::Match(tok->link(), ") ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") ("))
|
if (Token::Match(tok, "( &| %var%") && Token::Match(tok->link(), ") ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") ("))
|
||||||
tok = tok->link()->next();
|
tok = tok->link()->next();
|
||||||
if (Token::Match(tok->link(), ") ::| %type%"))
|
if (Token::Match(tok->link(), ") ::| %type%"))
|
||||||
tok = tok->link()->next();
|
tok = tok->link()->next();
|
||||||
else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [();,]"))
|
else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [();,]")) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
else if (Token::Match(tok, "( &| %var%") && Token::simpleMatch(tok->link(), ") ("))
|
innertype = true;
|
||||||
|
}
|
||||||
|
else if (Token::Match(tok, "( &| %var%") && Token::simpleMatch(tok->link(), ") (")) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
innertype = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
state.op.push(tok);
|
state.op.push(tok);
|
||||||
while (Token::Match(tok, "%var%|*|&|<|::")) {
|
while (Token::Match(tok, "%var%|*|&|<|::")) {
|
||||||
|
@ -682,7 +687,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
|
||||||
} else if (tok->str() == "[" || tok->str() == "(")
|
} else if (tok->str() == "[" || tok->str() == "(")
|
||||||
compilePrecedence2(tok, state);
|
compilePrecedence2(tok, state);
|
||||||
compileUnaryOp(newtok, state, nullptr);
|
compileUnaryOp(newtok, state, nullptr);
|
||||||
if (Token::simpleMatch(tok, ") ,"))
|
if (innertype && Token::simpleMatch(tok, ") ,"))
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {
|
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {
|
||||||
Token* tok2 = tok;
|
Token* tok2 = tok;
|
||||||
|
|
|
@ -8394,6 +8394,7 @@ private:
|
||||||
ASSERT_EQUALS("adelete", testAst("delete[] a;"));
|
ASSERT_EQUALS("adelete", testAst("delete[] a;"));
|
||||||
ASSERT_EQUALS("ab.3c-(delete", testAst("delete[] a.b(3 - c);"));
|
ASSERT_EQUALS("ab.3c-(delete", testAst("delete[] a.b(3 - c);"));
|
||||||
ASSERT_EQUALS("a::new=", testAst("a = new (b) ::X;"));
|
ASSERT_EQUALS("a::new=", testAst("a = new (b) ::X;"));
|
||||||
|
ASSERT_EQUALS("aA1(new(bB2(new(,", testAst("a(new A(1)), b(new B(2))"));
|
||||||
|
|
||||||
// clang testsuite..
|
// clang testsuite..
|
||||||
ASSERT_EQUALS("const0(new", testAst("new const auto (0);"));
|
ASSERT_EQUALS("const0(new", testAst("new const auto (0);"));
|
||||||
|
|
Loading…
Reference in New Issue