AST; Fix wrong AST for initializer list
This commit is contained in:
parent
08184f4681
commit
2f984b201a
|
@ -943,10 +943,11 @@ static bool isForLoopCondition(const Token * const tok)
|
|||
parent->astParent()->astParent()->astOperand1()->str() == "for";
|
||||
}
|
||||
|
||||
static bool isZeroConstant(const Token *tok) {
|
||||
while (tok && tok->isCast())
|
||||
tok = tok->astOperand2() ? tok->astOperand2() : tok->astOperand1();
|
||||
return Token::simpleMatch(tok, "0") && !tok->isExpandedMacro();
|
||||
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,9 +844,10 @@ 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);
|
||||
tok = end;
|
||||
if (precedes(tok,end))
|
||||
tok = end;
|
||||
} else {
|
||||
state.op.push(tok);
|
||||
tok = tok->tokAt(2);
|
||||
|
|
|
@ -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