This commit is contained in:
parent
5721dca019
commit
322a1a5e8c
|
@ -4128,17 +4128,6 @@ static const Type* findVariableTypeIncludingUsedNamespaces(const SymbolDatabase*
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static const Token* findLambdaEndTokenWithoutAST(const Token* tok) {
|
||||
if (!(Token::simpleMatch(tok, "[") && tok->link()))
|
||||
return nullptr;
|
||||
tok = tok->link()->next();
|
||||
if (Token::simpleMatch(tok, "(") && tok->link())
|
||||
tok = tok->link()->next();
|
||||
if (!(Token::simpleMatch(tok, "{") && tok->link()))
|
||||
return nullptr;
|
||||
return tok->link()->next();
|
||||
}
|
||||
|
||||
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
||||
{
|
||||
// check for non-empty argument list "( ... )"
|
||||
|
|
|
@ -878,7 +878,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
|
|||
tok = tok->previous();
|
||||
return !Token::Match(tok, "new ::| %type%");
|
||||
}
|
||||
return true;
|
||||
return !findLambdaEndTokenWithoutAST(tok);
|
||||
};
|
||||
|
||||
if (doCompileScope(tok))
|
||||
|
@ -1327,6 +1327,17 @@ const Token* isLambdaCaptureList(const Token * tok)
|
|||
return params->astOperand1();
|
||||
}
|
||||
|
||||
const Token* findLambdaEndTokenWithoutAST(const Token* tok) {
|
||||
if (!(Token::simpleMatch(tok, "[") && tok->link()))
|
||||
return nullptr;
|
||||
tok = tok->link()->next();
|
||||
if (Token::simpleMatch(tok, "(") && tok->link())
|
||||
tok = tok->link()->next();
|
||||
if (!(Token::simpleMatch(tok, "{") && tok->link()))
|
||||
return nullptr;
|
||||
return tok->link()->next();
|
||||
}
|
||||
|
||||
static Token * createAstAtToken(Token *tok, bool cpp);
|
||||
|
||||
// Compile inner expressions inside inner ({..}) and lambda bodies
|
||||
|
|
|
@ -215,6 +215,7 @@ private:
|
|||
/// @}
|
||||
|
||||
const Token* isLambdaCaptureList(const Token* tok);
|
||||
const Token* findLambdaEndTokenWithoutAST(const Token* tok);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif // tokenlistH
|
||||
|
|
|
@ -6542,6 +6542,8 @@ private:
|
|||
|
||||
// #11378
|
||||
ASSERT_EQUALS("gT{(&[{= 0return", testAst("auto g = T{ [&]() noexcept -> int { return 0; } };"));
|
||||
|
||||
ASSERT_EQUALS("sf.{(i[{={", testAst("void g(int i) { S s{ .f = { [i]() {} } }; }"));
|
||||
}
|
||||
|
||||
void astcase() {
|
||||
|
|
Loading…
Reference in New Issue