Fixed #10831 ("Analysis failed (lambda not recognized)" with lamba default parameter in lambda signature)

This commit is contained in:
Daniel Marjamäki 2022-10-10 21:05:27 +02:00
parent ed06e29f7a
commit 584a428025
2 changed files with 8 additions and 2 deletions

View File

@ -489,6 +489,8 @@ struct AST_state {
explicit AST_state(bool cpp) : depth(0), inArrayAssignment(0), cpp(cpp), assign(0), inCase(false),stopAtColon(false), functionCallEndPar(nullptr) {}
};
static Token * createAstAtToken(Token *tok, bool cpp);
static Token* skipDecl(Token* tok, std::vector<Token*>* inner = nullptr)
{
if (!Token::Match(tok->previous(), "( %name%"))
@ -974,6 +976,9 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
squareBracket->astOperand1(roundBracket);
roundBracket->astOperand1(curlyBracket);
state.op.push(squareBracket);
for (tok = roundBracket->next(); precedes(tok, roundBracket->link()); tok = tok->next()) {
tok = createAstAtToken(tok, state.cpp);
}
tok = curlyBracket->link()->next();
continue;
}
@ -1361,8 +1366,6 @@ static bool isLambdaCaptureList(const Token * tok)
return true;
}
static Token * createAstAtToken(Token *tok, bool cpp);
// Compile inner expressions inside inner ({..}) and lambda bodies
static void createAstAtTokenInner(Token * const tok1, const Token *endToken, bool cpp)
{

View File

@ -6469,6 +6469,9 @@ private:
" const auto y = z;\n"
" switch (y) {}\n"
"};"));
// #10831
ASSERT_EQUALS("f{([= x{([=", testAst("void foo() { F f = [](t x = []() {}) {}; }"));
}
void astcase() {