Fix #10451 syntaxError with typedef and lambda

This commit is contained in:
chrchr 2022-03-14 13:15:40 +01:00
parent 0d336b868c
commit fdc7577c32
3 changed files with 17 additions and 2 deletions

View File

@ -192,7 +192,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
continue; continue;
else if (Token::Match(tok2, "%name% (") && mTokenizer->isFunctionHead(tok2->next(), "{;")) else if (Token::Match(tok2, "%name% (") && mTokenizer->isFunctionHead(tok2->next(), "{;"))
continue; continue;
else if (Token::Match(tok2, "%name% [")) else if (Token::Match(tok2, "%name% [|="))
continue; continue;
// skip template // skip template
else if (Token::simpleMatch(tok2, ";") && else if (Token::simpleMatch(tok2, ";") &&

View File

@ -658,7 +658,7 @@ private:
} }
void garbageCode43() { // #6703 void garbageCode43() { // #6703
ASSERT_THROW(checkCode("int { }; struct A<void> a = { }"), InternalError); checkCode("int { }; struct A<void> a = { }");
} }
void garbageCode44() { // #6704 void garbageCode44() { // #6704

View File

@ -356,6 +356,7 @@ private:
TEST_CASE(symboldatabase95); // #10295 TEST_CASE(symboldatabase95); // #10295
TEST_CASE(symboldatabase96); // #10126 TEST_CASE(symboldatabase96); // #10126
TEST_CASE(symboldatabase97); // #10598 - final class TEST_CASE(symboldatabase97); // #10598 - final class
TEST_CASE(symboldatabase98); // #10451
TEST_CASE(createSymbolDatabaseFindAllScopes1); TEST_CASE(createSymbolDatabaseFindAllScopes1);
TEST_CASE(createSymbolDatabaseFindAllScopes2); TEST_CASE(createSymbolDatabaseFindAllScopes2);
@ -4858,6 +4859,20 @@ private:
ASSERT_EQUALS(functok->function()->type, Function::Type::eConstructor); ASSERT_EQUALS(functok->function()->type, Function::Type::eConstructor);
} }
void symboldatabase98() { // #10451
GET_SYMBOL_DB("struct A { typedef struct {} B; };\n"
"void f() {\n"
" auto g = [](A::B b) -> void { A::B b2 = b; };\n" }
"};\n");
ASSERT(db);
ASSERT_EQUALS(3, db->scopeList.size());
const Token *functok = Token::findmatch(tokenizer.tokens(), "%name% (");
ASSERT(functok);
ASSERT(functok->function());
ASSERT_EQUALS(functok->function()->type, Function::Type::eConstructor);
}
void createSymbolDatabaseFindAllScopes1() { void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3); ASSERT(db->scopeList.size() == 3);