AST; Fix wrong AST for initializer list
This commit is contained in:
parent
08184f4681
commit
2f984b201a
|
@ -943,7 +943,8 @@ static bool isForLoopCondition(const Token * const tok)
|
|||
parent->astParent()->astParent()->astOperand1()->str() == "for";
|
||||
}
|
||||
|
||||
static bool isZeroConstant(const Token *tok) {
|
||||
static bool isZeroConstant(const Token *tok)
|
||||
{
|
||||
while (tok && tok->isCast())
|
||||
tok = tok->astOperand2() ? tok->astOperand2() : tok->astOperand1();
|
||||
return Token::simpleMatch(tok, "0") && !tok->isExpandedMacro();
|
||||
|
|
|
@ -844,8 +844,9 @@ static void compileTerm(Token *&tok, AST_state& state)
|
|||
} else if (state.cpp && iscpp11init(tok)) {
|
||||
if (state.op.empty() || Token::Match(tok->previous(), "[{,]") || Token::Match(tok->tokAt(-2), "%name% (")) {
|
||||
if (Token::Match(tok, "{ !!}")) {
|
||||
Token *end = tok->link();
|
||||
Token *const end = tok->link();
|
||||
compileUnaryOp(tok, state, compileExpression);
|
||||
if (precedes(tok,end))
|
||||
tok = end;
|
||||
} else {
|
||||
state.op.push(tok);
|
||||
|
|
|
@ -5815,6 +5815,7 @@ private:
|
|||
ASSERT_EQUALS("f1{2{,3{,{x,(", testAst("f({{1},{2},{3}},x);"));
|
||||
ASSERT_EQUALS("a1{ b2{", testAst("auto a{1}; auto b{2};"));
|
||||
ASSERT_EQUALS("var1ab::23,{,{4ab::56,{,{,{", testAst("auto var{{1,a::b{2,3}}, {4,a::b{5,6}}};"));
|
||||
ASSERT_EQUALS("var{{,{,{{", testAst("auto var{ {{},{}}, {} };"));
|
||||
|
||||
// Initialization with decltype(expr) instead of a type
|
||||
ASSERT_EQUALS("decltypex((", testAst("decltype(x)();"));
|
||||
|
|
Loading…
Reference in New Issue