Fixed #7934 (Wrong AST for 'for (i=0;cond;({min(x,10);}))')

This commit is contained in:
Daniel Marjamäki 2017-04-02 19:44:33 +02:00
parent de80d41ef4
commit abb43b6a81
2 changed files with 5 additions and 1 deletions

View File

@ -1008,11 +1008,15 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
if (tok->str() == "{") {
if (Token::simpleMatch(tok->previous(), "( {"))
;
// Lambda function
else if (Token::simpleMatch(tok->astParent(), "(") &&
Token::simpleMatch(tok->astParent()->astParent(), "[") &&
tok->astParent()->astParent()->astOperand1() &&
tok == tok->astParent()->astParent()->astOperand1()->astOperand1())
;
// function argument is initializer list
else if (tok->astParent() && (tok->astParent()->str() == "," || Token::Match(tok->astParent()->previous(), "%name% (")))
;
else
continue;

View File

@ -8028,7 +8028,7 @@ private:
ASSERT_EQUALS("xa{((= bc( yd{((= ef(",
testAst("x=(int)(a({b(c);}));" // don't hang
"y=(int)(d({e(f);}));"));
ASSERT_EQUALS("QT_WA{{,( QT_WA{{,( x1=",
ASSERT_EQUALS("QT_WA{{,( x0= QT_WA{{,( x1= x2=",
testAst("QT_WA({},{x=0;});" // don't hang
"QT_WA({x=1;},{x=2;});"));
ASSERT_EQUALS("xMACROtypeT=value1=,{({=",