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
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
continue;
else if (Token::Match(tok2, "%name% (") && mTokenizer->isFunctionHead(tok2->next(), "{;"))
continue;
else if (Token::Match(tok2, "%name% ["))
else if (Token::Match(tok2, "%name% [|="))
continue;
// skip template
else if (Token::simpleMatch(tok2, ";") &&
Expand Down
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ void Tokenizer::simplifyTypedef()
structRemoved = true;
typeStart = typeStart->next();
}
if (Token::Match(typeStart, "struct|class") && Token::Match(tok2, "%name% ::"))
if (Token::Match(typeStart, "struct|class|union") && Token::Match(tok2, "%name% ::"))
typeStart = typeStart->next();

if (sameStartEnd)
Expand Down
2 changes: 1 addition & 1 deletion test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class TestGarbage : public TestFixture {
}

void garbageCode43() { // #6703
ASSERT_THROW(checkCode("int { }; struct A<void> a = { }"), InternalError);
checkCode("int { }; struct A<void> a = { }");
}

void garbageCode44() { // #6704
Expand Down
21 changes: 21 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(symboldatabase95); // #10295
TEST_CASE(symboldatabase96); // #10126
TEST_CASE(symboldatabase97); // #10598 - final class
TEST_CASE(symboldatabase98); // #10451

TEST_CASE(createSymbolDatabaseFindAllScopes1);
TEST_CASE(createSymbolDatabaseFindAllScopes2);
Expand Down Expand Up @@ -4858,6 +4859,26 @@ class TestSymbolDatabase : public TestFixture {
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(5, db->scopeList.size());
}
{
GET_SYMBOL_DB("typedef union {\n"
" int i;\n"
"} U;\n"
"template <auto U::*>\n"
"void f();\n");
ASSERT(db);
ASSERT_EQUALS(2, db->scopeList.size());
}
}

void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3);
Expand Down