Fix issue 9563: new daca crash: findLambdaEndToken not finding end token (#2472)
This commit is contained in:
parent
c30d839b98
commit
e07801a891
|
@ -3431,7 +3431,10 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
|||
if (tok->str() == "=") {
|
||||
initArgCount++;
|
||||
if (tok->strAt(1) == "[") {
|
||||
tok = findLambdaEndToken(tok->next());
|
||||
const Token* lambdaStart = tok->next();
|
||||
tok = findLambdaEndToken(lambdaStart);
|
||||
if (!tok)
|
||||
throw InternalError(lambdaStart, "Analysis failed (lambda not recognized). If the code is valid then please report this failure.", InternalError::INTERNAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -765,6 +765,8 @@ static void compileTerm(Token *&tok, AST_state& state)
|
|||
while (Token::Match(tok, "%name%|%str%"))
|
||||
tok = tok->next();
|
||||
}
|
||||
if (Token::Match(tok, "%name% %assign%"))
|
||||
tok = tok->next();
|
||||
}
|
||||
} else if (tok->str() == "{") {
|
||||
const Token *prev = tok->previous();
|
||||
|
@ -1265,8 +1267,8 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
|
|||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
} else if (Token::simpleMatch(tok->link(), "] (") && Token::Match(tok->link()->linkAt(1), ") .|{")) {
|
||||
Token *bodyStart = tok->link()->linkAt(1)->next();
|
||||
} else if (const Token * lambdaEnd = findLambdaEndScope(tok)) {
|
||||
Token *bodyStart = lambdaEnd->link();
|
||||
if (Token::Match(bodyStart, ". %name%") && bodyStart->originalName() == "->") {
|
||||
bodyStart = bodyStart->next();
|
||||
while (Token::Match(bodyStart, "%name%|::"))
|
||||
|
|
|
@ -8168,6 +8168,14 @@ private:
|
|||
" if (a<b, decltype(0)>::d) {}\n"
|
||||
" });\n"
|
||||
"}\n"))
|
||||
|
||||
// #9563
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("template <typename> struct a;\n"
|
||||
"template <typename b, typename... c> struct a<b(c...)> {\n"
|
||||
" template <typename d> a(d);\n"
|
||||
"};\n"
|
||||
"void e(\n"
|
||||
" int, a<void()> f = [] {});\n"))
|
||||
}
|
||||
void checkIfCppCast() {
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"
|
||||
|
|
Loading…
Reference in New Issue