@@ -1013,7 +1013,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
10131013 else
10141014 compileUnaryOp (tok, state, compileScope);
10151015 } else if (tok->str () == " [" ) {
1016- if (state.cpp && isPrefixUnary (tok, /* cpp*/ true ) && Token::Match (tok->link (), " ] (|{|< " )) { // Lambda
1016+ if (state.cpp && isPrefixUnary (tok, /* cpp*/ true ) && Token::Match (tok->link (), " ] [({<.] " )) { // Lambda
10171017 // What we do here:
10181018 // - Nest the round bracket under the square bracket.
10191019 // - Nest what follows the lambda (if anything) with the lambda opening [
@@ -1062,7 +1062,18 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
10621062 continue ;
10631063 }
10641064 } else {
1065- Token* const curlyBracket = squareBracket->link ()->next ();
1065+ Token* curlyBracket = squareBracket->link ()->next ();
1066+ if (Token::simpleMatch (curlyBracket, " ." )) { // trailing return type
1067+ curlyBracket = curlyBracket->next ();
1068+ while (Token::Match (curlyBracket, " %type%|%name%|::|&|&&|*|<|(" )) {
1069+ if (curlyBracket->link ())
1070+ curlyBracket = curlyBracket->link ()->next ();
1071+ else
1072+ curlyBracket = curlyBracket->next ();
1073+ }
1074+ }
1075+ if (!Token::simpleMatch (curlyBracket, " {" ))
1076+ throw InternalError (tok, " Syntax error in lambda" , InternalError::AST );
10661077 squareBracket->astOperand1 (curlyBracket);
10671078 state.op .push (squareBracket);
10681079 tok = curlyBracket->link () ? curlyBracket->link ()->next () : nullptr ;
0 commit comments