diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index d3ff6aba1..f679c510a 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -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; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 34934ece8..fca695793 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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=,{({=",