Fix crash with lambda capture (#1960)
This commit is contained in:
parent
2bd026dd2a
commit
65af02f0cf
|
@ -668,7 +668,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
const Token *lambdaStartToken = lambdaEndToken->link();
|
||||
const Token * argStart = lambdaStartToken->astParent();
|
||||
const Token * funcStart = Token::simpleMatch(argStart, "[") ? argStart : argStart->astParent();
|
||||
addGlobalFunction(scope, tok, argStart, funcStart);
|
||||
const Function * function = addGlobalFunction(scope, tok, argStart, funcStart);
|
||||
if (!function)
|
||||
mTokenizer->syntaxError(tok);
|
||||
tok = lambdaStartToken;
|
||||
} else if (tok->str() == "{") {
|
||||
if (isExecutableScope(tok)) {
|
||||
|
@ -679,6 +681,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
tok = tok->link();
|
||||
}
|
||||
}
|
||||
// syntax error?
|
||||
if (!scope)
|
||||
mTokenizer->syntaxError(tok);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6609,7 +6609,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
|
|||
Token *eq = tok2;
|
||||
|
||||
while (tok2) {
|
||||
if (Token::Match(tok2, "{|("))
|
||||
if (Token::Match(tok2, "{|(|["))
|
||||
tok2 = tok2->link();
|
||||
|
||||
else if (!isC() && tok2->str() == "<" && tok2->previous()->isName() && !tok2->previous()->varId())
|
||||
|
|
|
@ -7840,6 +7840,12 @@ private:
|
|||
ASSERT_NO_THROW(tokenizeAndStringify("auto f(int& i) { return [&, i] {}; }"))
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("auto f(int& i) { return [&, i = std::move(i)] {}; }"))
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("auto f(int& i) { return [=, i = std::move(i)] {}; }"))
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("struct c {\n"
|
||||
" void d() {\n"
|
||||
" int a;\n"
|
||||
" auto b = [this, a] {};\n"
|
||||
" }\n"
|
||||
"};\n"))
|
||||
}
|
||||
|
||||
void noCrash1() {
|
||||
|
|
Loading…
Reference in New Issue