Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4311,7 +4311,13 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
initArgCount++;
if (tok->strAt(1) == "[") {
const Token* lambdaStart = tok->next();
tok = type == eLambda ? findLambdaEndTokenWithoutAST(lambdaStart) : findLambdaEndToken(lambdaStart);
if (type == eLambda)
tok = findLambdaEndTokenWithoutAST(lambdaStart);
else {
tok = findLambdaEndToken(lambdaStart);
if (!tok)
tok = findLambdaEndTokenWithoutAST(lambdaStart);
}
if (!tok)
throw InternalError(lambdaStart, "Analysis failed (lambda not recognized). If the code is valid then please report this failure.", InternalError::INTERNAL);
}
Expand Down
12 changes: 12 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(functionArgs17);
TEST_CASE(functionArgs18); // #10376
TEST_CASE(functionArgs19); // #10376
TEST_CASE(functionArgs20);

TEST_CASE(functionImplicitlyVirtual);

Expand Down Expand Up @@ -2707,6 +2708,17 @@ class TestSymbolDatabase : public TestFixture {
ASSERT_EQUALS(3, func->argCount());
}

void functionArgs20() { // #11769
const char code[] = "void f(void *(*g)(void *) = [](void *p) { return p; }) {}";
GET_SYMBOL_DB(code);
ASSERT(db != nullptr);
const Scope *scope = db->functionScopes.front();
const Function *func = scope->function;
ASSERT_EQUALS(1, func->argCount());
const Variable* arg = func->getArgumentVar(0);
TODO_ASSERT(arg->hasDefault());
}

void functionImplicitlyVirtual() {
GET_SYMBOL_DB("class base { virtual void f(); };\n"
"class derived : base { void f(); };\n"
Expand Down