Fixed #10051 (AST: Wrong ast for function call with initializer list)

This commit is contained in:
Daniel Marjamäki 2020-12-26 18:33:29 +01:00
parent 56fbd4cba5
commit d024eb3ee0
2 changed files with 7 additions and 3 deletions

View File

@ -839,8 +839,11 @@ static void compileTerm(Token *&tok, AST_state& state)
tok = tok->next();
} else if (state.cpp && iscpp11init(tok)) {
if (state.op.empty() || Token::Match(tok->previous(), "[{,]") || Token::Match(tok->tokAt(-2), "%name% (")) {
if (Token::Match(tok, "{ !!}"))
if (Token::Match(tok, "{ !!}")) {
Token *end = tok->link();
compileUnaryOp(tok, state, compileExpression);
tok = end;
}
else {
state.op.push(tok);
tok = tok->tokAt(2);

View File

@ -7880,8 +7880,8 @@ private:
ASSERT_EQUALS("xMACROtype.T=value.1=,{({=",
testAst("x = { MACRO( { .type=T, .value=1 } ) }")); // don't hang: MACRO({..})
ASSERT_EQUALS("fori10=i{;;( i--", testAst("for (i=10;i;({i--;}) ) {}"));
ASSERT_EQUALS("c{0{,{(",
testAst("c({{}, {0}}, {0.0f});"));
ASSERT_EQUALS("c{1{,{2.3f{,(",
testAst("c({{}, {1}}, {2.3f});"));
// function pointer
TODO_ASSERT_EQUALS("todo", "va_argapvoid((,(*0=", testAst("*va_arg(ap, void(**) ()) = 0;"));
@ -7924,6 +7924,7 @@ private:
ASSERT_EQUALS("a{b{,{return", testAst("return{{a},{b}};"));
ASSERT_EQUALS("stdvector::", testAst("std::vector<std::vector<int>>{{},{}}"));
ASSERT_EQUALS("abR{{,P(,((", testAst("a(b(R{},{},P()));"));
ASSERT_EQUALS("f1{2{,3{,{x,(", testAst("f({{1},{2},{3}},x);"));
}
void astbrackets() { // []