Fixed AST generation for C++11-style initialization (#6528)

This commit is contained in:
PKEuS 2015-11-06 17:34:26 +01:00
parent cc783b0186
commit be36539ad7
2 changed files with 5 additions and 2 deletions

View File

@ -576,7 +576,9 @@ static void compileTerm(Token *&tok, AST_state& state)
}
}
} else if (tok->str() == "{") {
if (!state.inArrayAssignment && tok->strAt(-1) != "=") {
if (tok->previous() && tok->previous()->isName()) {
compileBinOp(tok, state, compileExpression);
} else if (!state.inArrayAssignment && tok->strAt(-1) != "=") {
state.op.push(tok);
tok = tok->link()->next();
} else {
@ -746,7 +748,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
state.op.push(tok->next());
tok = tok->link()->next();
compileBinOp(tok, state, compilePrecedence2);
} else if (tok && (tok->str() == "[" || tok->str() == "("))
} else if (tok && (tok->str() == "[" || tok->str() == "(" || tok->str() == "{"))
compilePrecedence2(tok, state);
else if (innertype && Token::simpleMatch(tok, ") [")) {
tok = tok->next();

View File

@ -8237,6 +8237,7 @@ private:
ASSERT_EQUALS("abc{d:?=", testAst("a=b?c<X>{}:d;"));
ASSERT_EQUALS("abc12,{d:?=", testAst("a=b?c<X>{1,2}:d;"));
ASSERT_EQUALS("a::12,{", testAst("::a{1,2};")); // operator precedence
ASSERT_EQUALS("Abc({newreturn", testAst("return new A {b(c)};"));
}
void astbrackets() { // []